######################################################################## LEXICAL GRAMMAR ######################################################################## input = { inputelement } inputelement = whitespace | comment | token token = ident | number | string | '(' | ')' | ... /* to complete */ comment = '/' '/' { cchar } ident = letter { letter | digit | '_' } number = "0" | digit1 { digit } string = '"' { schar } '"' whitespace = ' ' | '\t' | '\f' | '\n' letter = 'a' | ... | 'z' | 'A' | ... | 'Z' digit = '0' | digit1 digit1 = '1' | ... | '9' cchar = all characters except for '\n' schar = all characters except for '\n' and '"' ######################################################################## SYNTACTICAL GRAMMAR ######################################################################## Program = { Declaration ";" } Body Body = { Statement ";" } [ Expression ] Declaration = "def" ident "(" Formals ")" ":" Type "=" Expression Formal = ident ":" Type Formals = [ Formal { "," Formal } ] Type = "Unit" | "Any" | "Int" | "List" "[" Type "]" | "(" Types ")" "=>" Type Types = [ Type { "," Type } ] Statement = "var" Formal "=" Expression | "while" "(" Expression ")" Expression | Expression Expression = "if" "(" Expression ")" Expression [ "else" Expression ] | ident "=" Expression | OrExpression OrExpression = AndExpression | OrExpression "|" AndExpression AndExpression = CmpExpression | AndExpression "&" CmpExpression CmpExpression = [ ListExpression CompOp ] ListExpression CompOp = "==" | "!=" | "<" | ">" | "<=" | ">=" ListExpression = SumExpression | SumExpression "::" ListExpression SumExpression = Term | SumExpression SumOp Term SumOp = "+" | "-" Term = [ Term ProdOp ] [ NegateOp ] Factor NegateOp = "-" | "!" ProdOp = "*" | "/" | "%" Factor = ident | number | string | "true" | "false" | "(" [ Expression ] ")" | "{" Body "}" | PredefFun Params | "List" Params | Factor Params PredefFun = "head" | "tail" | "isEmpty" Params = "(" Expressions ")" Expressions = [ Expression { "," Expression } ] ###################################################################### $Id: concrete_syntax.txt,v 1.1 2004/02/24 16:10:55 schinz Exp $