Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

3. Run ANTLR 3 on a simple grammar


To be written. Volunteers?

3.1 Create a simple grammar


To be written. Volunteers?

Java

Code Block
grammar Simple;

@header
{
    package antlr3.tutorial.simple;
}

OR : '||' ;

C#

Code Block
grammar Simple;

options 
{
    language=CSharp;
}

OR : '||' ;

Objective-C

Code Block
grammar Simple;

options 
{
    language=ObjC;
}

OR : '||' ;

C

Code Block
grammar Simple;

options 
{
    language=C;
}

OR : '||' ;

...

Construct

Description

Example

(...)*

Kleene closure - matches zero or more occurrences

LETTER DIGIT* - match a LETTER followed by zero or more occurrences of DIGIT

(...)+

Positive Kleene closure - matches one or more occurrences

('0'..'9')+ - match one or more occurrences of a numerical digit
LETTER (LETTER|DIGIT)+ - match a LETTER followed one or more occurrences of either LETTER or DIGIT

3.1 ANTLR 3 parser grammar syntax

Java

Code Block

parser grammar MyLangParser;

@header
{
    package antlr3.tutorial.mylang;
}

OR : '||' ;

4. Build and use a basic ANTLR 3 grammar

...

Java

Code Block

grammar Simple;

C#

code


grammar Simple;

options
{
   language=CSharp;
}

Objective-C

Code Block

grammar Simple;

options
{
   language=ObjC;
}

How about a more complex ANTLR 3 grammar?

...

Your five minutes are up!


To be written. Volunteers?