Browsable Pico Grammar

CC-BY

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]

Summary

Syntax

Type ::=
	[natural]::"natural"
Type ::=
	[nil]::"nil-type"
Type ::=
	[string]::"string"
Statement ::=
	[assign]::(var⟩:Id ":="val⟩:Expression)
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⟩:Declarationsbody⟩:{Statement ";"}* "end")
Declarations ::=
	"declare"decls⟩:{IdType ","}* ";"
Expression ::=
	[strcon]::⟨string⟩:String
Expression ::=
	[id]::⟨name⟩:Id
Expression ::=
	[natcon]::⟨natcon⟩:Natural
Expression ::=
	"("e⟩:Expression ")"
Expression ::=
	[concat]::(lhs⟩:Expression "||"rhs⟩:Expression)
Expression ::=
	[min]::(lhs⟩:Expression "-"rhs⟩:Expression)
Expression ::=
	[add]::(lhs⟩:Expression "+"rhs⟩:Expression)
IdType ::=
	[idtype]::(id⟩:Id ":"t⟩:Type)

GrammarLabMaintained by Dr. Vadim Zaytsev a.k.a. @grammarware. Last updated in September 2015. []