NAME ^

pir.pg - A PIR grammar for PGE.

TODO:

 1. fix Heredocs parsing
 2. Test and fix things

Some rules/tokens have names in capitals; these represent the pure token. Each such token has also a rule with the same name in lowercase, which does reports a syntax error if the token was not read. For instance, <STRING_CONST> will match a string constant, but <string_constant> will report an error if there was no STRING_CONST token.

Sub defs, sub pragmas, sub body and parameters ^

sub_pragmas

PIR instructions ^

Local declarations ^

Local declarations can be done using .local in normal context. TODO: how to declare locals in a macro? this needs to be fixed.

Const definition ^

Const definitions, a check is done for the constant type and the type of the constant value.

Macro body ^

In order to be able to parse macro identifiers, before the macro body is parsed, some rules are redefined. After parsing the macro body, they are restored.

Pragmas ^

Tokens ^

normal_label

this is a token, because no spaces are allowed between the IDENT and the colon.

Macro_target ^

In a macro, a target can also be a macro_id

Newlines ^

match the set of a newline and possible indention space 1 or more times this is necessary to be able to skip fully white lines (with some spaces/tabs in it). However, therefore it is also necessary to put the comments skipping here as well.

Keywords ^

PIR directives, PASM instructions and the Parrot datatypes (int, string, num, pmc) are keywords, and must not be used as identifiers.

PIR directives ^

TODO: put this in <%pir_directive> PIR directives


parrot