Skip to main content

module lang::flybytes::demo::func::Syntax

rascal-0.40.17
flybytes-0.2.8

Usage

import lang::flybytes::demo::func::Syntax;

Source code

http://github.com/usethesource/flybytes/blob/main/src/lang/flybytes/demo/func/Syntax.rsc

syntax Ident

lexical Ident =  [a-zA-Z][a-zA-Z0-9]* !>> [a-zA-Z0-9];

syntax Natural

lexical Natural = [0-9]+ !>> [0-9];

syntax LAYOUT

lexical LAYOUT = [\t-\n\r\ ];

syntax LAYOUTLIST

layout LAYOUTLIST = LAYOUT*  !>> [\t-\n\r\ ] ;

syntax Prog

start syntax Prog = prog: Func* ;

syntax Func

syntax Func = func: Ident name "(" {Ident ","}* ")" "=" Exp;

syntax Exp

syntax Exp = let: "let" {Binding ","}* "in" Exp "end"
| cond: "if" Exp "then" Exp "else" Exp "end"
| bracket "(" Exp ")"
| var: Ident
| nat: Natural
| call: Ident "(" {Exp ","}* ")"
> non-assoc (
left mul: Exp "*" Exp
| non-assoc div: Exp "/" Exp
)
> left (
left add: Exp "+" Exp
| left sub: Exp "-" Exp
)
>
non-assoc (
non-assoc gt: Exp "\>" Exp
| non-assoc lt: Exp "\<" Exp
| non-assoc geq: Exp "\>=" Exp
| non-assoc leq: Exp "\<=" Exp
)
>
right assign: Ident ":=" Exp
>
right seq: Exp ";" Exp;

syntax Binding

syntax Binding = binding: Ident "=" Exp;