SlideShare a Scribd company logo
Using ANTLR on real
      example

 convert “string combined” queries into
        parameterized queries
Simon Wiki says:

    ANTLR (pronounced Antler), or ANother Tool for Language
    Recognition, is a parser generator that uses LL(*) parsing.


    ANTLR takes as input a grammar that specifies a language and
    generates as output source code for a recognizer for that
    language. A language is specified using a context-free grammar
    which is expressed using Extended Backus–Naur Form (EBNF).


    ANTLR allows generating lexers, parsers, tree parsers, and
    combined lexer-parsers. Parsers can automatically generate
    abstract syntax trees which can be further processed with tree
    parsers. ANTLR provides a single consistent notation for specifying
    lexers, parsers, and tree parsers. This is in contrast with other
    parser/lexer generators and adds greatly to the tool's ease of use.
Used at least in following products:

    Drools, JBoss rule engine (DRL DSL)

    Hibernate, Java ORM (HQL DSL)

    NHibernate, .NET ORM (HQL DSL)

    Groovy, language for JVM

    Jython, language for JVM
Where we need ANTLR?

    Parsing a text stream of formal data

    Parsing a text stream of incomplete formal data

    Complex parsing

    Parsing with good error handling

    Writing Domain-Specific Language

    You have enough time and some data to parse...
Why just not use regular
            expression language?

    In most cases you should go with RegEx


    SO: “RegEx is a text search tool. If all you need to do is pull
    strings out of strings then it's often the hammer of choice.”


    SO: “ANTLR is a parser generator. If you need error messages
    and parse actions or any of the complicated things that
    come with a interpreter/compiler then it's a good option.”


    SO: “ANTLR has perfect support for "error-messages": they
    show line/column numbers and what was wrong. RegEx
    doesn't have this support.”


    ANTLR is a something (a-lot-of-things) on top of regular
    expression language.
ANTLR parsing workflow
Tools under ANTLR umbrella
 ANTLR3 Code Generation Targets:
 •
     Java, JavaScript (in sync with development)
 •
     C, C++, C#, Objective C, Ruby (almost in sync)
 •
     Python, ActionScript (current with 3.1 instead of
     3.4)
Tools under ANTLR umbrella
 ANTLR Grammars:
    Java, C, C++, ECMAScript, ANTLR, C#,
    PHP, Verilog, x86 Assembler, ISO SQL
    2003, PL/SQL, Clojure, XPath, Pascal,
    GraphViz Dot, Fortran, Python, CSS,
    Objective C, Lua, Ruby, Eiffel, ECMA
    CIL (.NET), Classic ASP, CORBA IDL
Tools under ANTLR umbrella
    Editors, IDEs, etc:
•
    ANTLRWorks, GUI IDE. http://antlr.org/works/
•
    Eclipse, NetBeans, JetBrains IDEA, Visual Studio
    integration.
•
    VIM syntax highlighter. https://github.com/rollxx/vim-
    antlr
•
    ANTLR-Mode for Emacs. http://antlr-
    mode.sourceforge.net/
ANTLRWorks. Editor window
ANTLRWorks. Interpreter window
Ambigious path visualization
ANTLRWorks. Interactive
     debugger
Eclipse. ANTLR integration
JetBrains IDEA. ANTRL integration
Sample syntax. CSV grammar
Real example. Test cases
•   Query without any parameters
•   Query with concat and variable
•   Query with dotted and escaped table names and single quote in sql
•   Query with function call and func args concat
•   Query with function call with several func args
•   Query with nested function call with several func args
•   Query with concat and two variables
•   Insert query with four params
•   Query with dotted param and function name and funciton arg
•   Endline symbol will be dropped from query
•   Single line comment will be dropped from query
•   Strip single quote only if it next to parameter
•   Query with like keyword (FAILED)
•   Refactor multiline query (FAILED)
Real example. Syntax tree




strsql = "SELECT * FROM TABLE_NAME WHERE
    FIRST_FIELD = " & DOTTED.PARAM_VAR & "
    AND SECOND_FIELD = " &
    DOTTED.FUNC_CALL(DOTTED.FUNC_ARG)
Grammar:1. Options, tokens
Grammar:2. Lexer/parser members
Grammar:3. Top-level elements
Grammar:4. End
Questions are Welcome!




                         31337
Ad

Recommended

An Introduction to ANTLR
An Introduction to ANTLR
Morteza Zakeri
 
ANTLR4 in depth
ANTLR4 in depth
Владимир Кожаев
 
Apache Beam (incubating)
Apache Beam (incubating)
Apache Apex
 
ANTLR4 and its testing
ANTLR4 and its testing
Knoldus Inc.
 
Akka-intro-training-public.pdf
Akka-intro-training-public.pdf
BernardDeffarges
 
Multithreading and Actors
Multithreading and Actors
Diego Pacheco
 
YugaByte DB Internals - Storage Engine and Transactions
YugaByte DB Internals - Storage Engine and Transactions
Yugabyte
 
Introduction to Actor Model and Akka
Introduction to Actor Model and Akka
Yung-Lin Ho
 
Observability in Java: Getting Started with OpenTelemetry
Observability in Java: Getting Started with OpenTelemetry
DevOps.com
 
ELK Stack
ELK Stack
Phuc Nguyen
 
Universal metrics with Apache Beam
Universal metrics with Apache Beam
Etienne Chauchot
 
Terraform Basics
Terraform Basics
Mohammed Fazuluddin
 
Reactive stream processing using Akka streams
Reactive stream processing using Akka streams
Johan Andrén
 
Introduction to Spring webflux
Introduction to Spring webflux
Knoldus Inc.
 
Introduction to Prometheus and Cortex (WOUG)
Introduction to Prometheus and Cortex (WOUG)
Weaveworks
 
Apache Flink, AWS Kinesis, Analytics
Apache Flink, AWS Kinesis, Analytics
Araf Karsh Hamid
 
Security as Code: A DevSecOps Approach
Security as Code: A DevSecOps Approach
VMware Tanzu
 
Intro to Time Series
Intro to Time Series
InfluxData
 
Query and audit logging in cassandra
Query and audit logging in cassandra
Vinay Kumar Chella
 
GraalVM
GraalVM
NexThoughts Technologies
 
Kibana Tutorial | Kibana Dashboard Tutorial | Kibana Elasticsearch | ELK Stac...
Kibana Tutorial | Kibana Dashboard Tutorial | Kibana Elasticsearch | ELK Stac...
Edureka!
 
Hibernate architecture
Hibernate architecture
Anurag
 
Introduction to ELK
Introduction to ELK
YuHsuan Chen
 
Agile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven Design
Araf Karsh Hamid
 
Introduction To TensorFlow | Deep Learning Using TensorFlow | TensorFlow Tuto...
Introduction To TensorFlow | Deep Learning Using TensorFlow | TensorFlow Tuto...
Edureka!
 
Introduction to elasticsearch
Introduction to elasticsearch
hypto
 
Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...
Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...
StampedeCon
 
Elasticsearch for beginners
Elasticsearch for beginners
Neil Baker
 
Antlr Conference Drools & Hibernate
Antlr Conference Drools & Hibernate
Alexandre Porcelli
 
Architectures n-tiers
Architectures n-tiers
Heithem Abbes
 

More Related Content

What's hot (20)

Observability in Java: Getting Started with OpenTelemetry
Observability in Java: Getting Started with OpenTelemetry
DevOps.com
 
ELK Stack
ELK Stack
Phuc Nguyen
 
Universal metrics with Apache Beam
Universal metrics with Apache Beam
Etienne Chauchot
 
Terraform Basics
Terraform Basics
Mohammed Fazuluddin
 
Reactive stream processing using Akka streams
Reactive stream processing using Akka streams
Johan Andrén
 
Introduction to Spring webflux
Introduction to Spring webflux
Knoldus Inc.
 
Introduction to Prometheus and Cortex (WOUG)
Introduction to Prometheus and Cortex (WOUG)
Weaveworks
 
Apache Flink, AWS Kinesis, Analytics
Apache Flink, AWS Kinesis, Analytics
Araf Karsh Hamid
 
Security as Code: A DevSecOps Approach
Security as Code: A DevSecOps Approach
VMware Tanzu
 
Intro to Time Series
Intro to Time Series
InfluxData
 
Query and audit logging in cassandra
Query and audit logging in cassandra
Vinay Kumar Chella
 
GraalVM
GraalVM
NexThoughts Technologies
 
Kibana Tutorial | Kibana Dashboard Tutorial | Kibana Elasticsearch | ELK Stac...
Kibana Tutorial | Kibana Dashboard Tutorial | Kibana Elasticsearch | ELK Stac...
Edureka!
 
Hibernate architecture
Hibernate architecture
Anurag
 
Introduction to ELK
Introduction to ELK
YuHsuan Chen
 
Agile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven Design
Araf Karsh Hamid
 
Introduction To TensorFlow | Deep Learning Using TensorFlow | TensorFlow Tuto...
Introduction To TensorFlow | Deep Learning Using TensorFlow | TensorFlow Tuto...
Edureka!
 
Introduction to elasticsearch
Introduction to elasticsearch
hypto
 
Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...
Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...
StampedeCon
 
Elasticsearch for beginners
Elasticsearch for beginners
Neil Baker
 
Observability in Java: Getting Started with OpenTelemetry
Observability in Java: Getting Started with OpenTelemetry
DevOps.com
 
Universal metrics with Apache Beam
Universal metrics with Apache Beam
Etienne Chauchot
 
Reactive stream processing using Akka streams
Reactive stream processing using Akka streams
Johan Andrén
 
Introduction to Spring webflux
Introduction to Spring webflux
Knoldus Inc.
 
Introduction to Prometheus and Cortex (WOUG)
Introduction to Prometheus and Cortex (WOUG)
Weaveworks
 
Apache Flink, AWS Kinesis, Analytics
Apache Flink, AWS Kinesis, Analytics
Araf Karsh Hamid
 
Security as Code: A DevSecOps Approach
Security as Code: A DevSecOps Approach
VMware Tanzu
 
Intro to Time Series
Intro to Time Series
InfluxData
 
Query and audit logging in cassandra
Query and audit logging in cassandra
Vinay Kumar Chella
 
Kibana Tutorial | Kibana Dashboard Tutorial | Kibana Elasticsearch | ELK Stac...
Kibana Tutorial | Kibana Dashboard Tutorial | Kibana Elasticsearch | ELK Stac...
Edureka!
 
Hibernate architecture
Hibernate architecture
Anurag
 
Introduction to ELK
Introduction to ELK
YuHsuan Chen
 
Agile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven Design
Araf Karsh Hamid
 
Introduction To TensorFlow | Deep Learning Using TensorFlow | TensorFlow Tuto...
Introduction To TensorFlow | Deep Learning Using TensorFlow | TensorFlow Tuto...
Edureka!
 
Introduction to elasticsearch
Introduction to elasticsearch
hypto
 
Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...
Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...
StampedeCon
 
Elasticsearch for beginners
Elasticsearch for beginners
Neil Baker
 

Viewers also liked (8)

Antlr Conference Drools & Hibernate
Antlr Conference Drools & Hibernate
Alexandre Porcelli
 
Architectures n-tiers
Architectures n-tiers
Heithem Abbes
 
Automated antlr tree walker
Automated antlr tree walker
geeksec80
 
Impulsione sua carreira contribuindo para projetos open source
Impulsione sua carreira contribuindo para projetos open source
Alexandre Porcelli
 
20 examples on Domain-Specific Modeling Languages
20 examples on Domain-Specific Modeling Languages
Juha-Pekka Tolvanen
 
Introduction à l'approche ADM de l'OMG
Introduction à l'approche ADM de l'OMG
Olivier Le Goaër
 
Antlr V3
Antlr V3
guest5024494
 
20100629 dsl-poitou-charentes-jug
20100629 dsl-poitou-charentes-jug
BENOIS Jérôme
 
Antlr Conference Drools & Hibernate
Antlr Conference Drools & Hibernate
Alexandre Porcelli
 
Architectures n-tiers
Architectures n-tiers
Heithem Abbes
 
Automated antlr tree walker
Automated antlr tree walker
geeksec80
 
Impulsione sua carreira contribuindo para projetos open source
Impulsione sua carreira contribuindo para projetos open source
Alexandre Porcelli
 
20 examples on Domain-Specific Modeling Languages
20 examples on Domain-Specific Modeling Languages
Juha-Pekka Tolvanen
 
Introduction à l'approche ADM de l'OMG
Introduction à l'approche ADM de l'OMG
Olivier Le Goaër
 
20100629 dsl-poitou-charentes-jug
20100629 dsl-poitou-charentes-jug
BENOIS Jérôme
 
Ad

Similar to Using ANTLR on real example - convert "string combined" queries into parameterized queries (20)

2. introduction
2. introduction
Saeed Parsa
 
How to create a programming language
How to create a programming language
Robert Mamore
 
ANTLR - Writing Parsers the Easy Way
ANTLR - Writing Parsers the Easy Way
Michael Yarichuk
 
Antlr
Antlr
Arlene Smith
 
introduction_to_antlr 3.ppt
introduction_to_antlr 3.ppt
TathagatoBose
 
Lexing and parsing
Lexing and parsing
Elizabeth Smith
 
Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 1)
Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 1)
Binary Studio
 
Programming_Language_Syntax.ppt
Programming_Language_Syntax.ppt
Amrita Sharma
 
Parser
Parser
Mallikarjun Rao
 
Code Generation Cambridge 2013 Introduction to Parsing with ANTLR4
Code Generation Cambridge 2013 Introduction to Parsing with ANTLR4
Oliver Zeigermann
 
Antlr Conexaojava
Antlr Conexaojava
Fernando Meyer
 
2. introduction to compiler
2. introduction to compiler
Saeed Parsa
 
TDC 2020 - Implementing a Mini-Language
TDC 2020 - Implementing a Mini-Language
Luciano Sabença
 
Antlr4 get the right tool for the job
Antlr4 get the right tool for the job
Alexander Pacha
 
Syntax
Syntax
ABDERRAHMAN ID -SAID
 
Control structure
Control structure
baran19901990
 
Generative programming (mostly parser generation)
Generative programming (mostly parser generation)
Ralf Laemmel
 
04 Syntax Analysis.pdf
04 Syntax Analysis.pdf
movamag594
 
DSLs for fun and profit by Jukka Välimaa
DSLs for fun and profit by Jukka Välimaa
Montel Intergalactic
 
Ch2
Ch2
kinnarshah8888
 
How to create a programming language
How to create a programming language
Robert Mamore
 
ANTLR - Writing Parsers the Easy Way
ANTLR - Writing Parsers the Easy Way
Michael Yarichuk
 
introduction_to_antlr 3.ppt
introduction_to_antlr 3.ppt
TathagatoBose
 
Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 1)
Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 1)
Binary Studio
 
Programming_Language_Syntax.ppt
Programming_Language_Syntax.ppt
Amrita Sharma
 
Code Generation Cambridge 2013 Introduction to Parsing with ANTLR4
Code Generation Cambridge 2013 Introduction to Parsing with ANTLR4
Oliver Zeigermann
 
2. introduction to compiler
2. introduction to compiler
Saeed Parsa
 
TDC 2020 - Implementing a Mini-Language
TDC 2020 - Implementing a Mini-Language
Luciano Sabença
 
Antlr4 get the right tool for the job
Antlr4 get the right tool for the job
Alexander Pacha
 
Generative programming (mostly parser generation)
Generative programming (mostly parser generation)
Ralf Laemmel
 
04 Syntax Analysis.pdf
04 Syntax Analysis.pdf
movamag594
 
DSLs for fun and profit by Jukka Välimaa
DSLs for fun and profit by Jukka Välimaa
Montel Intergalactic
 
Ad

Recently uploaded (20)

Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
Supporting the NextGen 911 Digital Transformation with FME
Supporting the NextGen 911 Digital Transformation with FME
Safe Software
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
June Patch Tuesday
June Patch Tuesday
Ivanti
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
Supporting the NextGen 911 Digital Transformation with FME
Supporting the NextGen 911 Digital Transformation with FME
Safe Software
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
June Patch Tuesday
June Patch Tuesday
Ivanti
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 

Using ANTLR on real example - convert "string combined" queries into parameterized queries

  • 1. Using ANTLR on real example convert “string combined” queries into parameterized queries
  • 2. Simon Wiki says:  ANTLR (pronounced Antler), or ANother Tool for Language Recognition, is a parser generator that uses LL(*) parsing.  ANTLR takes as input a grammar that specifies a language and generates as output source code for a recognizer for that language. A language is specified using a context-free grammar which is expressed using Extended Backus–Naur Form (EBNF).  ANTLR allows generating lexers, parsers, tree parsers, and combined lexer-parsers. Parsers can automatically generate abstract syntax trees which can be further processed with tree parsers. ANTLR provides a single consistent notation for specifying lexers, parsers, and tree parsers. This is in contrast with other parser/lexer generators and adds greatly to the tool's ease of use.
  • 3. Used at least in following products:  Drools, JBoss rule engine (DRL DSL)  Hibernate, Java ORM (HQL DSL)  NHibernate, .NET ORM (HQL DSL)  Groovy, language for JVM  Jython, language for JVM
  • 4. Where we need ANTLR?  Parsing a text stream of formal data  Parsing a text stream of incomplete formal data  Complex parsing  Parsing with good error handling  Writing Domain-Specific Language  You have enough time and some data to parse...
  • 5. Why just not use regular expression language?  In most cases you should go with RegEx  SO: “RegEx is a text search tool. If all you need to do is pull strings out of strings then it's often the hammer of choice.”  SO: “ANTLR is a parser generator. If you need error messages and parse actions or any of the complicated things that come with a interpreter/compiler then it's a good option.”  SO: “ANTLR has perfect support for "error-messages": they show line/column numbers and what was wrong. RegEx doesn't have this support.”  ANTLR is a something (a-lot-of-things) on top of regular expression language.
  • 7. Tools under ANTLR umbrella ANTLR3 Code Generation Targets: • Java, JavaScript (in sync with development) • C, C++, C#, Objective C, Ruby (almost in sync) • Python, ActionScript (current with 3.1 instead of 3.4)
  • 8. Tools under ANTLR umbrella ANTLR Grammars: Java, C, C++, ECMAScript, ANTLR, C#, PHP, Verilog, x86 Assembler, ISO SQL 2003, PL/SQL, Clojure, XPath, Pascal, GraphViz Dot, Fortran, Python, CSS, Objective C, Lua, Ruby, Eiffel, ECMA CIL (.NET), Classic ASP, CORBA IDL
  • 9. Tools under ANTLR umbrella Editors, IDEs, etc: • ANTLRWorks, GUI IDE. http://antlr.org/works/ • Eclipse, NetBeans, JetBrains IDEA, Visual Studio integration. • VIM syntax highlighter. https://github.com/rollxx/vim- antlr • ANTLR-Mode for Emacs. http://antlr- mode.sourceforge.net/
  • 15. JetBrains IDEA. ANTRL integration
  • 17. Real example. Test cases • Query without any parameters • Query with concat and variable • Query with dotted and escaped table names and single quote in sql • Query with function call and func args concat • Query with function call with several func args • Query with nested function call with several func args • Query with concat and two variables • Insert query with four params • Query with dotted param and function name and funciton arg • Endline symbol will be dropped from query • Single line comment will be dropped from query • Strip single quote only if it next to parameter • Query with like keyword (FAILED) • Refactor multiline query (FAILED)
  • 18. Real example. Syntax tree strsql = "SELECT * FROM TABLE_NAME WHERE FIRST_FIELD = " & DOTTED.PARAM_VAR & " AND SECOND_FIELD = " & DOTTED.FUNC_CALL(DOTTED.FUNC_ARG)