Просмотр исходного кода

Add the (not working) null keyword

pull/4/head
mtardy 4 лет назад
Родитель
Сommit
95cb13a326
1 измененных файлов: 6 добавлений и 2 удалений
  1. +6
    -2
      calc.leg

+ 6
- 2
calc.leg Просмотреть файл

@ -161,7 +161,9 @@ oop intern(char *ident)
oop update_symbol_value(oop symbol, oop integer) oop update_symbol_value(oop symbol, oop integer)
{ {
_checkType(symbol, Symbol); _checkType(symbol, Symbol);
_checkType(integer, Integer);
// For now it will fail with assigning to null
// because for now we can write "a=2 b=a" because everything is passed by value
_checkType(integer, Integer);
symbol->Symbol.value = integer; symbol->Symbol.value = integer;
return symbol; return symbol;
} }
@ -191,17 +193,19 @@ neg = MINUS n:neg { set(n, Integer, value, -get(n, Integer, value)); $$ = n
| n:value { $$ = n } | n:value { $$ = n }
value = n:NUMBER { $$ = n } value = n:NUMBER { $$ = n }
| NULL { $$ = null; // For now it doesn't work because of _checktype in update_symbol_value() }
| l:IDENT { $$ = get(l, Symbol, value); // Will result in an assertion failed if ident is undefined } | l:IDENT { $$ = get(l, Symbol, value); // Will result in an assertion failed if ident is undefined }
- = [ \t]* - = [ \t]*
NUMBER = < [0-9]+ > - { $$ = makeInteger(atoi(yytext)) } NUMBER = < [0-9]+ > - { $$ = makeInteger(atoi(yytext)) }
IDENT = < [a-zA-Z][a-zA-Z0-9_]* > - { $$ = intern(yytext) }
PLUS = '+' - PLUS = '+' -
MINUS = '-' - MINUS = '-' -
MULTI = '*' - MULTI = '*' -
DIVIDE = '/' - DIVIDE = '/' -
MODULO = '%' - MODULO = '%' -
EQUAL = '=' - EQUAL = '=' -
IDENT = < [a-zA-Z][a-zA-Z0-9_]* > - { $$ = intern(yytext) }
NULL = 'null' -
%% %%

Загрузка…
Отмена
Сохранить