Skip to main content

module examples::modfun::Syntax

rascal-0.34.0
typepal-0.8.10

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 ";"
;