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