Procesadores de Lenguajes

3º. 2º cuatrimestre. Itinerario de Computación. Grado en Ingeniería Informática. ULL


Organization ULL-ESIT-PL-1920   Github Classroom ULL-ESIT-PL-1920   Campus Virtual PL   Chat Chat   Profesor Casiano

Table of Contents

Egg Initial Syntax

expression: (STRING | NUMBER | WORD) apply 

apply: /* vacio */
     | '(' (expression ',')* expression? ')' apply

Token definitions

WHITES = /^(\s|#.*)*/
STRING = /^"([^"]*)"/
NUMBER = /^\d+\b/
WORD   = /^[^\s(),"]+/

Ejecuciones

[~/.../PLgrado/eloquentjsegg(inicial)]$ node egg.js 'print(+)'
[Function: anonymous]
[~/.../PLgrado/eloquentjsegg(inicial)]$ node egg.js 'print(4,)'
4
[~/.../PLgrado/eloquentjsegg(inicial)]$ node egg.js '8()'
/Users/casiano/local/src/javascript/PLgrado/eloquentjsegg/egg.js:76
TypeError: Applying a non-function
    at evaluate (/Users/casiano/local/src/javascript/PLgrado/eloquentjsegg/egg.js:76:15)

[~/.../PLgrado/eloquentjsegg(inicial)]$ node egg.js '"hello"(2,3)'
TypeError: Applying a non-function
    at evaluate (/Users/casiano/local/src/javascript/PLgrado/eloquentjsegg/egg.js:76:15)

[~/.../PLgrado/eloquentjsegg(inicial)]$ node egg.js '+()'
[~/.../PLgrado/eloquentjsegg(inicial)]$ node egg.js '+(2,)'
[~/.../PLgrado/eloquentjsegg(inicial)]$ node egg.js 'print(+())'
NaN
[~/.../PLgrado/eloquentjsegg(inicial)]$ node egg.js 'print(+(2,))'
NaN

Your Comments

Comment with Disqus