module examples::smallOO::Syntax
rascal-0.40.16
typepal-0.14.8
Usage
import examples::smallOO::Syntax;
Source code
http://github.com/usethesource/typepal/src/examples/smallOO/Syntax.rsc
Dependencies
extend lang::std::Layout;
syntax Module
start syntax Module = "module" Identifier moduleName Import* imports Declaration* declarations;
syntax Import
syntax Import = "import" Identifier moduleName;
syntax Declaration
syntax Declaration
= "class" Identifier className "{" Declaration* declarations "}"
| Type returnType Identifier functionName "(" {Parameter ","}* parameters ")" "=" Expression returnExpression ";"
| Type fieldType Identifier fieldName ";"
;
syntax Parameter
syntax Parameter = Type tp Identifier name;
syntax Expression
syntax Expression
= Identifier id
| Expression "." Identifier id
| Literal l
| Identifier functionName "(" {Expression ","}* parameters ")"
| Expression "." Identifier functionName "(" {Expression ","}* parameters ")"
| Expression "+" Expression
;
syntax Identifier
lexical Identifier = ([a-z A-Z _][a-z A-Z _ 0-9]* !>> [a-z A-Z _ 0-9]) \ Keywords;
syntax Literal
lexical Literal
= Integer
| String
;
syntax Integer
lexical Integer = [0-9]+ !>> [0-9];
syntax String
lexical String = [\"] ![\"]* [\"];
syntax Type
lexical Type
= "int"
| "str"
| Identifier className
;
syntax Keywords
keyword Keywords = "module" | "class" | "import" | "int" | "str";