Skip to main content

module examples::fun::Syntax

rascal-0.34.0
typepal-0.8.10

Usage

import examples::fun::Syntax;

Source code

http://github.com/usethesource/typepal/src/examples/fun/Syntax.rsc

Dependencies

extend examples::CommonLex;

syntax Fun

start syntax Fun
= Expression
;

syntax Type

syntax Type 
= "bool"
| "int"
| "str"
| left Type from "-\>" Type to
;

syntax Expression

syntax Expression 
= Id name
| Integer intcon
| Boolean boolcon
| String strcon
| bracket "(" Expression e ")"
> left Expression lhs "+" Expression rhs
> left Expression lhs "&&" Expression rhs
| "fun" Id name ":" Type tp "{" Expression exp "}"
> left Expression exp1 "(" Expression exp2 ")"
| "let" Id name ":" Type tp "=" Expression exp1 "in" Expression exp2 "end"
| "if" Expression cond "then" Expression thenPart "else" Expression elsePart "fi"
;

syntax Reserved

keyword Reserved 
= "if" | "then" | "else" | "fi" |
"let" | "in" | "fun" | "end" |
"int" | "bool"
;