Versions Compared

Key

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

...


To be written. Volunteers?

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 : '||' ;

3.2 ANTLR 3 lexer grammar syntax

Java

Code Block
lexer grammar MyLangLexer;

@header
{
    package antlr3.tutorial.mylang;
}

OR : '||' ;

...

4. Build and use a basic ANTLR 3 grammar


To be written. Volunteers?

Java

Code Block
grammar Simple;

C#

Code Block
grammar Simple;

options
{
   language=CSharp;
}

Objective-C

Code Block
grammar Simple;

options
{
   language=ObjC;
}

...

How about a more complex ANTLR 3 grammar

...

?


To be written. Volunteers?

Sure, we'll use one from the examples-v3 distribution

What next?

Read the Antlr 3 Documentation

...