Browsable Pico Grammar

CC-BY

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]

Summary

Syntax

Type ::=
	[natural]::"natural"
	[nil]::"nil-type"
	[string]::"string"
Statement ::=
	[assign]::(var⟩: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")
Program ::=
	[program]::("begin"decls⟩:Declarationsbody⟩:{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⟩:Id ":"t⟩:Type)
Id ::=
	string
String ::=
	""" string """
Natural ::=
	integer

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