NAME ^

lua.pg - a Lua grammar in PGE

GRAMMAR RULES ^

The grammar rules are according to the original Lua parser as defined lparser.c in the lua distribution.

EXPRESSIONS ^

Operator precedence is implemented using an optable.

HELPER RULES ^

Helper rules will match a specific token, otherwise a syntax error is generated. These rules make the grammar more readable, so the calls to syntax_error() are not all over the grammar, but only in these rules.

TOKENS ^

Name ^

an identifier MUST start on a word boundary. If the \b is removed, this is allowed: a=1b=2, which of course should be an error.

Strings ^

A string can be either a single-quoted, double-quoted or a long string. Long strings are parsed using a custom parsing method.

Keywords ^

Lua keywords may not be used as identifiers. To make sure the longest identifier is matched, so that identifiers that start with a keyword is still an identifier, a keyword should end at a word boundary. This way, for instance, the identifier format is not read as for.


parrot