Skip to main content

module examples::modfun::Syntax

rascal-0.40.16
typepal-0.14.8

Usage

import examples::modfun::Syntax;

Source code

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

Dependencies

extend examples::fun::Syntax;

syntax ModId

lexical ModId   = ([A-Z][a-z0-9]* !>> [a-z0-9]) \ Reserved;

syntax Reserved

keyword Reserved = "module" | "import" | "def";

syntax ModFun

start syntax ModFun 
= ModuleDecl* modules
;

syntax ModuleDecl

syntax ModuleDecl
= "module" ModId mid "{" Decl* decls "}"
;

syntax Decl

syntax Decl
= ImportDecl importDecl
| VarDecl varDecl
;

syntax ImportDecl

syntax ImportDecl
= "import" ModId mid ";"
;

syntax VarDecl

syntax VarDecl
= "def" Id id ":" Type tp "=" Expression expression ";"
;