• ANTLR Syntax

    Posted on November 4, 2013 by in MediaWiki

    Basic syntax

    Basic syntax of ANTLR grammar language
    Syntax Description
    T Token
    r Rule
    r1 : (ra | rb)*
    Rule 1 is repeat of zero-or-more rule A and rule B
    ‘<string>’ String sequence
    {<action>} Program action
    {<predicate>}? Semantic predicate – external interpreting received tokens (like if identifier is variable or nor).
    {<gated predicate>}?=>
    (<subrule>)=> Syntactic predicate – matching input tokens to decide what alternate will be chosen.
    r? Optional rule
    r* Zero-or-many repeats of rule
    r+ One-or-more repeats of rule
    (<r1>|<r2>) Alternative occurrence rule 1 or rule 2
    (<r1>|<r2>)? Alternative optional occurrence of rule 1 or 2
    (<r1>|<r2>)* Zero-or-more occurrences of rule 1 or 2
    (<r1>|<r2>)+ One-or-more occurrences of rule 1 or 2
    . Wildcard

    Syntactic predicate

    • How to write syntactic predicated – http://www.antlr.org:8080/pipermail/antlr-interest/2005-January/011023.html


    • http://www.antlr.org/doc/glossary.html

You must be logged in to post a comment.