Is there a list of reserved words in ANTLR grammars?

I recently created an ANTLR3 analysis rule

options : foo bar;

which did not compile, and it took me a while to find out what optionsis the reserved word (AntlrWorks indicated an error, but not why). Is there a list of reserved words in ANTLR and are there better rules in naming conventions (which can help avoid this)?

+2
source share
2 answers

The reserved words for ANTLR v3 are:

    Keyword | Description
    --------- + ---------------------------------------- ----------------
    scope | Dynamically-scoped attribute
    fragment | lexer rule is a helper rule, not real token for parser
    lexer    |  grammar type
    tree     |  grammar type
    parser   |  grammar type
    grammar  |  grammar header
    returns  |  rule return value(s)
    throws   |  rule throws exception(s)
    catch    |  catch rule exceptions
    finally  |  do this no matter what
    options  |  grammar or rule options
    tokens   |  can add tokens with this; usually imaginary tokens
    import   |  import grammar(s)

: https://web.archive.org/web/20120314155217/http://www.antlr.org/wiki/display/ANTLR3/ANTLR+Cheat+Sheet ( )

" " w.r.t. ( , , , ...).

+4

.

, , , , , "enum", "enum".

, . Java- , , , , , .

+1

Source: https://habr.com/ru/post/1724917/


All Articles