Advertisement
cardel

Proyecto FLP

May 20th, 2018
820
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 3.02 KB | None | 0 0
  1. #lang eopl
  2.  
  3. (define lexica
  4. '((white-sp
  5.    (whitespace) skip)
  6.   (comment
  7.    ("%" (arbno (not #\newline))) skip)
  8.   (identificador
  9.    (letter (arbno (or letter digit "?"))) symbol)
  10.   (numero
  11.    (digit (arbno digit)) number)
  12.   (numero
  13.    ("-" digit (arbno digit)) number)
  14.   (numero
  15.    (digit (arbno digit) "." digit (arbno digit)) number)
  16.   (numero
  17.    ("-" digit (arbno digit) "." digit (arbno digit)) number)
  18.   (caracter ("'" (or digit letter) "'") symbol)
  19.   (cadena ("\"" (or digit letter) (arbno (or letter digit)) "\"") string)
  20.  
  21.   ))
  22.  
  23. (define gramatica
  24.   '(
  25.     (programa (expresion) a-programa)
  26.     (expresion (bool-expresion) bool-exp)
  27.     (expresion (numero) numero-exp)
  28.     (expresion (caracter) carater-exp)
  29.     (expresion ("ok") ok-exp)
  30.     (expresion ("var" (separated-list identificador "=" expresion ",") "in" expresion "end") var-exp)
  31.     (expresion ("let" (separated-list identificador "=" expresion ",") "in" expresion "end") let-exp)
  32.     (expresion ("let rec" (arbno identificador "(" (separated-list expresion ",") ")" "=" expresion) "in" expresion "end") letrec-exp)
  33.     (expresion ("set" identificador "=" expresion) set-exp)
  34.     (expresion ("begin" expresion (separated-list expresion ";") "end") begin-exp)
  35.     (expresion (primitiva "(" (arbno expresion) ")") prim-exp)
  36.     (expresion ("if" bool-expresion "then" expresion
  37.                      (arbno "elseif" bool-expresion "then" expresion)
  38.                      "else" expresion
  39.                      "end") if-exp)
  40.  
  41.     (expresion ("proc" "(" (separated-list identificador ",") ")" expresion "end") proc-exp)
  42.     (expresion ("apply" identificador "(" (separated-list expresion ",") ")" "end") apply-exp)
  43.     (expresion ("meth" "(" identificador "," (separated-list identificador ",") ")" expresion "end") meth-exp)
  44.     (expresion ("for" identificador "=" expresion "to" expresion "do" expresion "end") for-exp)
  45.     (expresion ("object" "{" (arbno identificador "=>" expresion) "}") obj-exp)
  46.     (expresion ("get" identificador "." identificador) get-exp)
  47.     (expresion ("send" identificador "." identificador "("(separated-list identificador ",") ")") send-exp)
  48.     (expresion ("update" identificador "." identificador ":=" expresion) update-exp)
  49.     (expresion ("clone" "(" identificador (separated-list identificador ",") ")") clone-exp)
  50.     (primitiva ("+") sum-prim)
  51.     (primitiva ("-") minus-prim)
  52.     (primitiva ("*") plus-prim)
  53.     (primitiva ("%") mod-prim)
  54.     (primitiva ("&") text-prim)
  55.     (bool-expresion ("true") true-exp)
  56.     (bool-expresion ("false") false-exp)
  57.     (bool-expresion (bool-primitiva "("(separated-list expresion ",") ")") bool-exp-prim)
  58.     (bool-expresion (bool-oper "(" (separated-list bool-expresion ",") ")") bool-exp-op)
  59.     (bool-primitiva ("<") minor-prim)
  60.     (bool-primitiva (">") mayor-prim)
  61.     (bool-primitiva ("<=") minorigual-prim)
  62.     (bool-primitiva (">=") mayorigual-prim)
  63.     (bool-primitiva ("!=") diferent-prim)
  64.     (bool-oper ("not") not-op)
  65.     (bool-oper ("and") and-op)
  66.     (bool-oper ("or") or-op)
  67.   ))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement