a grammar

Mar 10, 2007 21:38



program : program declaration
| declaration

declaration : Symbol Symbol ':' valueList
| Symbol Symbol '(' paramList ')' statement
| Symbol '`' Operator '`' '(' paramList ')' statement

statement : value ';'
| Return value ';'
| Return ';'
| flow
| '{' statements '}'

statements : statements statement
| statement

valueList : valueList ',' value
| value
| {- empty -}

paramList : paramList ',' param
| param
| {- empty -}

param : Symbol
| Symbol Symbol

value : declaration
| '`' Operator '`' '(' valueList ')'
| value Operator value
| Operator value
| Symbol '(' valueList ')'
| value '`' Symbol '`' value
| '`' Symbol '`' value
| '[' valueList ']'
| Symbol
| Operator
| Character
| String
| Integer
| '(' value ')'

flow : selection

selection : If '(' value ')' statement elsif

elsif : Elsif '(' value ')' statement elsif
| any

any : Any statement else
| else

else : Else statement
| {- empty -}

this has got some notable issues, the most glaring of which is the ability to have function parameters that don't have types but no way to declare variables with no particular type or functions whose return type isn't declared.

languages, programming

Previous post Next post
Up