Clasificación de Tokens


En base a un número inicial, se imprime la serie de números consecutivos hasta 10.

Identificador: [a-z]+
Número: [0-9]+
Lexema Nombre
read read
x identificador
repeat repeat
x identificador
:= :=
x identificador
+ +
1 número
; ;
write1 error
x identificador
until until
x identificador
< <
10 número

Calcula factorial de un número.

Identificador: var[0-9]+|[a-z]+
Número: [0-5]
Lexema Nombre
read read
va16 error
; ;
if if
var1 identificador
> >
0 número
then then
fact identificador
:= :=
1 número
; ;
repeat repeat
fact identificador
:= :=
fact identificador
* *
var1 identificador
; ;
var1 identificador
:= :=
var1 identificador
- -
1 número
until2 error
var1 identificador
:= :=
0 número
; ;
write write
fact identificador
end end

Si al sumar num1 y num2 es menor a límite, se imprime el resultado; si no, se restan.

Identificador: [a-z]+|num[0-2]+
Número: [0-2]+
Lexema Nombre
read read
limite identificador
; ;
read45 error
num1 identificador
; ;
read read
num2 identificador
; ;
if if
( (
numero1 error
+ +
num2 identificador
) )
< <
limite_2 error
then then
write write
num1 identificador
+ +
num2 identificador
else else
write write
num1 identificador
- -
num2 identificador
end end