Skip to main content

module examples::modules::Syntax

rascal-0.40.16
typepal-0.14.8

Usage

import examples::modules::Syntax;

Source code

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

Dependencies

extend lang::std::Layout;

syntax Reserved

keyword Reserved =  "struct" | "int" | "import";

syntax Program

start syntax Program =
"module" ModuleId
Import* imports
TopLevelDecl* declarations;

syntax ModuleId

lexical ModuleId
= {Id "::"}+ moduleName
;

syntax Id

lexical Id 
= (([a-z A-Z 0-9 _] - [u s]) !<< ([a-z A-Z] - [u s])[a-z A-Z 0-9 _]* !>> [a-z A-Z 0-9 _]) \ Reserved
;

syntax Import

syntax Import
= "import" ModuleId
;

syntax TopLevelDecl

syntax TopLevelDecl
= "struct" Id "{" DeclInStruct* declarations "}"
;

syntax DeclInStruct

syntax DeclInStruct
= Type ty
;

syntax Type

syntax Type
= Id id
;