diff --git a/parser/antlr/prog8.g4 b/parser/antlr/prog8.g4 index 34d163b28..c5e117cf9 100644 --- a/parser/antlr/prog8.g4 +++ b/parser/antlr/prog8.g4 @@ -73,9 +73,12 @@ ARRAYSIG : cpuregister: 'A' | 'X' | 'Y'; register: 'A' | 'X' | 'Y' | 'AX' | 'AY' | 'XY' | 'Pc' | 'Pz' | 'Pn' | 'Pv' | 'R0' | 'R1' | 'R2' | 'R3' | 'R4' | 'R5' | 'R6' | 'R7' | 'R8' | 'R9' | 'R10' | 'R11' | 'R12' | 'R13' | 'R14' | 'R15'; -module : (directive | block | EOL)* EOF ; +// A module (file) consists of zero or more directives or blocks, in any order. +// If there are more than one, then they must be separated by EOL (one or more newlines). +// However, trailing EOL is NOT required. +module: EOL? ((directive | block) (EOL (directive | block))*)? EOL? EOF; -block: identifier integerliteral? '{' EOL (block_statement | EOL) * '}' (EOL | EOF) ; +block: identifier integerliteral? '{' EOL (block_statement | EOL)* '}'; block_statement: