Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #lang eopl
- (define lexica
- '((white-sp
- (whitespace) skip)
- (comment
- ("%" (arbno (not #\newline))) skip)
- (identificador
- (letter (arbno (or letter digit "?"))) symbol)
- (numero
- (digit (arbno digit)) number)
- (numero
- ("-" digit (arbno digit)) number)
- (numero
- (digit (arbno digit) "." digit (arbno digit)) number)
- (numero
- ("-" digit (arbno digit) "." digit (arbno digit)) number)
- (caracter ("'" (or digit letter) "'") symbol)
- (cadena ("\"" (or digit letter) (arbno (or letter digit)) "\"") string)
- ))
- (define gramatica
- '(
- (programa (expresion) a-programa)
- (expresion (bool-expresion) bool-exp)
- (expresion (numero) numero-exp)
- (expresion (caracter) carater-exp)
- (expresion ("ok") ok-exp)
- (expresion ("var" (separated-list identificador "=" expresion ",") "in" expresion "end") var-exp)
- (expresion ("let" (separated-list identificador "=" expresion ",") "in" expresion "end") let-exp)
- (expresion ("let rec" (arbno identificador "(" (separated-list expresion ",") ")" "=" expresion) "in" expresion "end") letrec-exp)
- (expresion ("set" identificador "=" expresion) set-exp)
- (expresion ("begin" expresion (separated-list expresion ";") "end") begin-exp)
- (expresion (primitiva "(" (arbno expresion) ")") prim-exp)
- (expresion ("if" bool-expresion "then" expresion
- (arbno "elseif" bool-expresion "then" expresion)
- "else" expresion
- "end") if-exp)
- (expresion ("proc" "(" (separated-list identificador ",") ")" expresion "end") proc-exp)
- (expresion ("apply" identificador "(" (separated-list expresion ",") ")" "end") apply-exp)
- (expresion ("meth" "(" identificador "," (separated-list identificador ",") ")" expresion "end") meth-exp)
- (expresion ("for" identificador "=" expresion "to" expresion "do" expresion "end") for-exp)
- (expresion ("object" "{" (arbno identificador "=>" expresion) "}") obj-exp)
- (expresion ("get" identificador "." identificador) get-exp)
- (expresion ("send" identificador "." identificador "("(separated-list identificador ",") ")") send-exp)
- (expresion ("update" identificador "." identificador ":=" expresion) update-exp)
- (expresion ("clone" "(" identificador (separated-list identificador ",") ")") clone-exp)
- (primitiva ("+") sum-prim)
- (primitiva ("-") minus-prim)
- (primitiva ("*") plus-prim)
- (primitiva ("%") mod-prim)
- (primitiva ("&") text-prim)
- (bool-expresion ("true") true-exp)
- (bool-expresion ("false") false-exp)
- (bool-expresion (bool-primitiva "("(separated-list expresion ",") ")") bool-exp-prim)
- (bool-expresion (bool-oper "(" (separated-list bool-expresion ",") ")") bool-exp-op)
- (bool-primitiva ("<") minor-prim)
- (bool-primitiva (">") mayor-prim)
- (bool-primitiva ("<=") minorigual-prim)
- (bool-primitiva (">=") mayorigual-prim)
- (bool-primitiva ("!=") diferent-prim)
- (bool-oper ("not") not-op)
- (bool-oper ("and") and-op)
- (bool-oper ("or") or-op)
- ))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement