Grammar extracted by Vadim Zaytsev, see the Grammar Zoo entry for details: toy/pico/unknown/rascal/extracted
Source used for this grammar: Jurgen Vinju, lang::pico::syntax::Main
, 2011–2012 [Explore]
Type
, Statement
, Program
, Declarations
, Expression
, IdType
), 1 root (Program
), 0 top (—), 3 bottom (Id
3, String
, Natural
).[natural]
, [nil]
, [string]
, [assign]
, [cond]
2, [loop]
, [program]
, [strcon]
, [id]
, [natcon]
, [concat]
, [min]
, [add]
, [idtype]
.⟨var⟩
, ⟨val⟩
, ⟨cond⟩
3, ⟨thenPart⟩
2, ⟨elsePart⟩
, ⟨body⟩
2, ⟨decls⟩
2, ⟨string⟩
, ⟨name⟩
, ⟨natcon⟩
, ⟨e⟩
, ⟨lhs⟩
3, ⟨rhs⟩
3, ⟨id⟩
, ⟨t⟩
.Type ::=
[natural]::"natural"
Type ::=
[nil]::"nil-type"
Type ::=
[string]::"string"
Statement ::= [assign]::Id ":=" ⟨val⟩:Expression⟨var⟩:
Statement ::= [cond]::"if" ⟨cond⟩:Expression "then" ⟨thenPart⟩:";" Statement "else" ⟨elsePart⟩:";" Statement "fi"
Statement ::= [loop]::"while" ⟨cond⟩:Expression "do" ⟨body⟩:";" Statement "od"
Statement ::= [cond]::"if" ⟨cond⟩:Expression "then" ⟨thenPart⟩:";" Statement "fi"
Program ::= [program]::"begin" ⟨decls⟩:Declarations ⟨body⟩:";" Statement "end"
Declarations ::= "declare" ⟨decls⟩:"," IdType ";"
Expression ::=
[strcon]::⟨string⟩:String
Expression ::=
[id]::⟨name⟩:Id
Expression ::=
[natcon]::⟨natcon⟩:Natural
Expression ::= "(" ⟨e⟩:Expression ")"
Expression ::= [concat]::Expression "||" ⟨rhs⟩:Expression⟨lhs⟩:
Expression ::= [min]::Expression "-" ⟨rhs⟩:Expression⟨lhs⟩:
Expression ::= [add]::Expression "+" ⟨rhs⟩:Expression⟨lhs⟩:
IdType ::= [idtype]::Id ":" ⟨t⟩:Type⟨id⟩: