|
|
@ -1,7 +1,6 @@
|
|
|
|
module Syntax
|
|
|
|
module Syntax
|
|
|
|
|
|
|
|
|
|
|
|
extend lang::std::Whitespace;
|
|
|
|
extend lang::std::Whitespace;
|
|
|
|
extend lang::std::Id;
|
|
|
|
|
|
|
|
extend lang::std::ASCII;
|
|
|
|
extend lang::std::ASCII;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -108,7 +107,7 @@ syntax Lhs = Id ("[" Expr "]")?
|
|
|
|
|
|
|
|
|
|
|
|
syntax SubProgCall = 'readln'"(" LhsList ")"
|
|
|
|
syntax SubProgCall = 'readln'"(" LhsList ")"
|
|
|
|
| 'writeln'"(" ExprList ")"
|
|
|
|
| 'writeln'"(" ExprList ")"
|
|
|
|
> Id \ 'writeln' \ 'readln' \ 'skip' ("(" ExprList ")")?
|
|
|
|
> Id ("(" ExprList ")")?
|
|
|
|
;
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
syntax ExprList = Expr ("," Expr)*
|
|
|
|
syntax ExprList = Expr ("," Expr)*
|
|
|
@ -138,6 +137,14 @@ syntax Expr = "(" Expr ")"
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
Basic lexical constructs.
|
|
|
|
Basic lexical constructs.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
keyword Reserved = 'program' | 'const' | 'var' | 'array' | 'of' | 'integer'
|
|
|
|
|
|
|
|
| 'real' | 'function' | 'procedure' | 'begin' | 'end'
|
|
|
|
|
|
|
|
| 'skip' | 'if' | 'then' | 'else' | 'while' | 'do' | 'not'
|
|
|
|
|
|
|
|
| 'or' | 'and' | 'readln' | 'writeln'
|
|
|
|
|
|
|
|
;
|
|
|
|
|
|
|
|
lexical Id = ([a-z A-Z 0-9 _] !<< [a-z A-Z][a-z A-Z 0-9 _]* !>> [a-z A-Z 0-9 _]) \ Reserved
|
|
|
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
lexical Relop = "\<"|"\<="|"\>"|"\>="|"="|"\<\>";
|
|
|
|
lexical Relop = "\<"|"\<="|"\>"|"\>="|"="|"\<\>";
|
|
|
|
lexical Number = Digit+
|
|
|
|
lexical Number = Digit+
|
|
|
|
| Digit* "." Digit+
|
|
|
|
| Digit* "." Digit+
|
|
|
|