cleanup (removed .saves)
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@ -7,4 +7,5 @@ grammar.tab.h
|
||||
.vscode
|
||||
out
|
||||
tmp
|
||||
parser
|
||||
parser
|
||||
*.save
|
@ -1,3 +1,6 @@
|
||||
/* Syntax Analyzer with Bison (3.8.2) */
|
||||
/* The Translators - Spring 2025 */
|
||||
|
||||
%{
|
||||
#include <stdio.h>
|
||||
#include "../src/symbol_table.c"
|
||||
|
@ -1,255 +0,0 @@
|
||||
%{
|
||||
#include <stdio.h>
|
||||
#include "../src/symbol_table.c"
|
||||
extern int yylex(void);
|
||||
void yyerror(const char *err);
|
||||
extern char* yytext;
|
||||
extern int yychar;
|
||||
extern SymbolTable * cur;
|
||||
//char* cur_value;
|
||||
//char* cur_type;
|
||||
int token_tracker;
|
||||
extern int line_number;
|
||||
extern int column_number;
|
||||
extern FILE * yyin;
|
||||
%}
|
||||
|
||||
%union {
|
||||
int integ;
|
||||
char * words;
|
||||
}
|
||||
|
||||
//need subtraction only here
|
||||
%type <words> id_or_types
|
||||
%type <words> types
|
||||
%token <words> ID 101
|
||||
%token <words> T_INTEGER 201
|
||||
%token <words> T_ADDRESS 202
|
||||
%token <words> T_BOOLEAN 203
|
||||
%token <words> T_CHARACTER 204
|
||||
%token <words> T_STRING 205
|
||||
%token C_INTEGER 301
|
||||
%token C_NULL 302
|
||||
%token C_CHARACTER 303
|
||||
%token C_STRING 304
|
||||
%token C_TRUE 305
|
||||
%token C_FALSE 306
|
||||
%token WHILE 401
|
||||
%token IF 402
|
||||
%token THEN 403
|
||||
%token ELSE 404
|
||||
%token TYPE 405
|
||||
%token FUNCTION 406
|
||||
%token RETURN 407
|
||||
%token EXTERNAL 408
|
||||
%token AS 409
|
||||
%token L_PAREN 501
|
||||
%token R_PAREN 502
|
||||
%token L_BRACKET 503
|
||||
%token R_BRACKET 504
|
||||
%token L_BRACE 505
|
||||
%token R_BRACE 506
|
||||
%token SEMI_COLON 507
|
||||
%token COLON 508
|
||||
%token COMMA 509
|
||||
%token ARROW 510
|
||||
%token MUL 603
|
||||
%token DIV 604
|
||||
%token REM 605
|
||||
%token ADD 601
|
||||
%token LESS_THAN 606
|
||||
%token EQUAL_TO 607
|
||||
%token AND 610
|
||||
%token OR 611
|
||||
%token ASSIGN 608
|
||||
%token SUB_OR_NEG 602
|
||||
%token NOT 609
|
||||
%token DOT 612
|
||||
%token RESERVE 613
|
||||
%token RELEASE 614
|
||||
%token COMMENT 700
|
||||
|
||||
//precedence order
|
||||
%precedence RESERVE RELEASE
|
||||
%precedence DOT
|
||||
%precedence UMINUS
|
||||
%precedence NOT
|
||||
%left MUL DIV REM
|
||||
%left ADD SUB_OR_NEG
|
||||
%left LESS_THAN
|
||||
%left EQUAL_TO
|
||||
%left AND
|
||||
%left OR
|
||||
%left ASSIGN
|
||||
|
||||
%%
|
||||
|
||||
program:
|
||||
prototype_or_definition_list
|
||||
;
|
||||
|
||||
prototype_or_definition_list:
|
||||
prototype prototype_or_definition_list
|
||||
| definition prototype_or_definition_list
|
||||
| prototype
|
||||
| definition
|
||||
;
|
||||
|
||||
prototype:
|
||||
L_PAREN EXTERNAL R_PAREN FUNCTION ID COLON ID;
|
||||
|
||||
definition:
|
||||
TYPE ID COLON dblock
|
||||
| TYPE ID COLON constant ARROW ID
|
||||
| function_declaration
|
||||
| TYPE ID COLON id_or_types ARROW id_or_types
|
||||
| ID parameter ASSIGN sblock
|
||||
;
|
||||
|
||||
function_declaration:
|
||||
FUNCTION ID COLON ID
|
||||
| EXTERNAL FUNCTION ID COLON ID
|
||||
;
|
||||
|
||||
parameter:
|
||||
L_PAREN ID R_PAREN
|
||||
| AS L_PAREN idlist R_PAREN
|
||||
;
|
||||
|
||||
idlist:
|
||||
ID COMMA idlist
|
||||
| ID
|
||||
;
|
||||
|
||||
sblock:
|
||||
L_BRACE {cur = CreateScope(cur,2,2);} statement_list {cur = getParent(cur);} R_BRACE
|
||||
| L_BRACE {cur = CreateScope(cur,2,2);} dblock statement_list {cur = getParent(cur);} R_BRACE
|
||||
;
|
||||
|
||||
dblock:
|
||||
L_BRACKET declaration_list R_BRACKET;
|
||||
|
||||
declaration_list:
|
||||
declaration SEMI_COLON declaration_list
|
||||
| declaration
|
||||
;
|
||||
|
||||
|
||||
declaration:
|
||||
id_or_types COLON ID {CreateEntry(cur,$1,$3); }
|
||||
;
|
||||
|
||||
id_or_types:
|
||||
ID
|
||||
| types
|
||||
;
|
||||
|
||||
statement_list:
|
||||
compound_statement statement_list
|
||||
| compound_statement
|
||||
| simple_statement SEMI_COLON statement_list
|
||||
| simple_statement SEMI_COLON
|
||||
;
|
||||
|
||||
compound_statement:
|
||||
WHILE L_PAREN expression R_PAREN sblock
|
||||
| IF L_PAREN expression R_PAREN THEN sblock ELSE sblock
|
||||
| sblock
|
||||
;
|
||||
|
||||
simple_statement:
|
||||
assignable ASSIGN expression
|
||||
| RETURN expression
|
||||
;
|
||||
|
||||
assignable:
|
||||
ID
|
||||
| assignable ablock
|
||||
| assignable rec_op ID
|
||||
;
|
||||
|
||||
rec_op :
|
||||
DOT
|
||||
|
||||
expression:
|
||||
constant
|
||||
| SUB_OR_NEG expression %prec UMINUS
|
||||
| NOT expression
|
||||
| expression ADD expression
|
||||
| expression SUB_OR_NEG expression
|
||||
| expression MUL expression
|
||||
| expression DIV expression
|
||||
| expression REM expression
|
||||
| expression AND expression
|
||||
| expression OR expression
|
||||
| expression LESS_THAN expression
|
||||
| expression EQUAL_TO expression
|
||||
| assignable
|
||||
| L_PAREN expression R_PAREN
|
||||
| memOp assignable
|
||||
;
|
||||
|
||||
ablock:
|
||||
L_PAREN argument_list R_PAREN
|
||||
;
|
||||
|
||||
argument_list:
|
||||
expression COMMA argument_list
|
||||
| expression
|
||||
;
|
||||
|
||||
|
||||
memOp:
|
||||
RESERVE
|
||||
| RELEASE
|
||||
;
|
||||
|
||||
|
||||
constant:
|
||||
C_STRING
|
||||
| C_INTEGER
|
||||
| C_NULL
|
||||
| C_CHARACTER
|
||||
| C_TRUE
|
||||
| C_FALSE
|
||||
;
|
||||
|
||||
types:
|
||||
T_STRING
|
||||
| T_INTEGER
|
||||
| T_ADDRESS
|
||||
| T_CHARACTER
|
||||
| T_BOOLEAN
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
void yyerror(const char *err) {
|
||||
fprintf(stderr, "ERROR: %s at token %s at line number %d,column number %d\n", err,yytext,line_number,column_number);
|
||||
}
|
||||
/*
|
||||
int main(int argc, char * argv[]) {
|
||||
token_tracker = 1;
|
||||
cur=CreateScope(NULL,1,1);
|
||||
//int a;
|
||||
FILE * fp;
|
||||
if(argc > 1){
|
||||
fp = fopen(argv[1], "r");
|
||||
yyin = fp;
|
||||
} else {
|
||||
fp = stdin;
|
||||
yyin = fp;
|
||||
}
|
||||
yyparse();
|
||||
//while ((a = yyparse() != EOF){
|
||||
// token_tracker++;
|
||||
//printf("%d = a: yytext = %s: yychar = %d, token number: %d\n", a, yytext, yychar,token_tracker);
|
||||
//if(yytext[0] == '\n'){
|
||||
FILE* f = fdopen(1,"w");
|
||||
print_symbol_table(getAncestor(cur),f);
|
||||
fclose(f);
|
||||
// break;
|
||||
//}
|
||||
//}
|
||||
return 0;
|
||||
} */
|
@ -1,91 +0,0 @@
|
||||
/* Lexical Analyzer with Flex (1.6.0) */
|
||||
/* The Translators - Spring 2025 */
|
||||
|
||||
%option noyywrap
|
||||
%option header-file="flex.h"
|
||||
|
||||
%{
|
||||
#include <stdbool.h>
|
||||
#include "../tmp/grammar.tab.h"
|
||||
#include "../src/symbol_table.h"
|
||||
#ifndef DEBUG
|
||||
#define DEBUG 0
|
||||
#endif
|
||||
extern SymbolTable * cur;
|
||||
extern int tok_flag;
|
||||
extern void incr(int lnum,int cnum, int tok);
|
||||
extern void print_tok(int tok);
|
||||
|
||||
int line_number = 1, column_number = 1;
|
||||
%}
|
||||
|
||||
STARCOM [^\*]|\*+[^\)\*]+
|
||||
PARENCOM [^\)]|[^\*\)]+\)+
|
||||
COMMENT \(\*{STARCOM}*\*\)|\(\*{PARENCOM}*\*\)
|
||||
ID [A-Za-z_][0-9A-Za-z_]*
|
||||
DIGIT [0-9]
|
||||
CHAR \\n|\\t|\\'|[^'\n\t\\]|\\\\
|
||||
SCHAR \\n|\\t|\\\"|[^\"\n\\]
|
||||
|
||||
%%
|
||||
|
||||
"integer" {if(DEBUG) {printf( "T_INTEGER: %s (%d)\n", yytext, T_INTEGER);} else {if(tok_flag != NULL){print_tok(T_INTEGER);}incr(line_number,column_number,T_INTEGER);return T_INTEGER;}}
|
||||
"address" {if(DEBUG) {printf( "T_ADDRESS: %s (%d)\n", yytext, T_ADDRESS);} else {return T_ADDRESS;}}
|
||||
"Boolean" {if(DEBUG) {printf( "T_BOOLEAN: %s (%d)\n", yytext, T_BOOLEAN);} else {return T_BOOLEAN;}}
|
||||
"character" {if(DEBUG) {printf( "T_CHARACTER: %s (%d)\n", yytext, T_CHARACTER);} else {return T_CHARACTER;}}
|
||||
|
||||
"while" {if(DEBUG) {printf( "WHILE: %s (%d)\n", yytext, WHILE);} else {return WHILE;}}
|
||||
"if" {if(DEBUG) {printf( "IF: %s (%d)\n", yytext, IF);} else {return IF;}}
|
||||
"then" {if(DEBUG) {printf( "THEN: %s (%d)\n", yytext, THEN);} else {return THEN;}}
|
||||
"else" {if(DEBUG) {printf( "ELSE: %s (%d)\n", yytext, ELSE);} else {return ELSE;}}
|
||||
"type" {if(DEBUG) {printf( "TYPE: %s (%d)\n", yytext, TYPE);} else {return TYPE;}}
|
||||
"function" {if(DEBUG) {printf( "FUNCTION: %s (%d)\n", yytext, FUNCTION);} else {return FUNCTION;}}
|
||||
"return" {if(DEBUG) {printf( "RETURN: %s (%d)\n", yytext, RETURN);} else {return RETURN;}}
|
||||
"external" {if(DEBUG) {printf( "EXTERNAL: %s (%d)\n", yytext, EXTERNAL);} else {return EXTERNAL;}}
|
||||
"as" {if(DEBUG) {printf( "AS: %s (%d)\n", yytext, AS);} else {return AS;}}
|
||||
|
||||
"release" {if(DEBUG) {printf( "RELEASE: %s (%d)\n", yytext, RELEASE);} else {return RELEASE;}}
|
||||
"reserve" {if(DEBUG) {printf( "RESERVE: %s (%d)\n", yytext, RESERVE);} else {return RESERVE;}}
|
||||
|
||||
"+" {if(DEBUG) {printf( "ADD: %s (%d)\n", yytext, ADD);} else {return ADD;}}
|
||||
"-" {if(DEBUG) {printf( "SUB_OR_NEG: %s (%d)\n", yytext, SUB_OR_NEG);} else {return SUB_OR_NEG;}}
|
||||
"*" {if(DEBUG) {printf( "MUL: %s (%d)\n", yytext, MUL);} else {return MUL;}}
|
||||
"/" {if(DEBUG) {printf( "DIV: %s (%d)\n", yytext, DIV);} else {return DIV;}}
|
||||
"%" {if(DEBUG) {printf( "REM: %s (%d)\n", yytext, REM);} else {return REM;}}
|
||||
"<" {if(DEBUG) {printf( "LESS_THAN: %s (%d)\n", yytext, LESS_THAN);} else {return LESS_THAN;}}
|
||||
"=" {if(DEBUG) {printf( "EQUAL_TO: %s (%d)\n", yytext, EQUAL_TO);} else {return EQUAL_TO;}}
|
||||
":=" {if(DEBUG) {printf( "ASSIGN: %s (%d)\n", yytext, ASSIGN);} else {return ASSIGN;}}
|
||||
"!" {if(DEBUG) {printf( "NOT: %s (%d)\n", yytext, NOT);} else {return NOT;}}
|
||||
"&" {if(DEBUG) {printf( "AND: %s (%d)\n", yytext, AND);} else {return AND;}}
|
||||
"|" {if(DEBUG) {printf( "OR: %s (%d)\n", yytext, OR);} else {return OR;}}
|
||||
"." {if(DEBUG) {printf( "DOT: %s (%d)\n", yytext, DOT);} else {return DOT;}}
|
||||
|
||||
";" {if(DEBUG) {printf( "SEMI_COLON: %s (%d)\n", yytext, SEMI_COLON);} else {return SEMI_COLON;}}
|
||||
":" {if(DEBUG) {printf( "COLON: %s (%d)\n", yytext, COLON);} else {return COLON;}}
|
||||
"," {if(DEBUG) {printf( "COMMA: %s (%d)\n", yytext, COMMA);} else {return COMMA;}}
|
||||
"->" {if(DEBUG) {printf( "ARROW: %s (%d)\n", yytext, ARROW);} else {return ARROW;}}
|
||||
|
||||
{DIGIT}+ {if(DEBUG) {printf( "C_INTEGER: %s (%d)\n", yytext, C_INTEGER);} else {return C_INTEGER;}}
|
||||
'{CHAR}' {if(DEBUG) {printf( "C_CHARACTER: %s (%d)\n", yytext, C_CHARACTER);} else {return C_CHARACTER;}}
|
||||
\"{SCHAR}*\" {if(DEBUG) {printf( "C_STRING: %s (%d)\n", yytext, C_STRING);} else {return C_STRING;}}
|
||||
{COMMENT} {if(DEBUG) {printf( "COMMENT: %s (%d)\n", yytext, COMMENT);} else {/*return COMMENT;*/}}
|
||||
|
||||
"(" {if(DEBUG) {printf( "L_PAREN: %s (%d)\n", yytext, L_PAREN);} else {return L_PAREN;}}
|
||||
")" {if(DEBUG) {printf( "R_PAREN: %s (%d)\n", yytext, R_PAREN);} else {return R_PAREN;}}
|
||||
"[" {if(DEBUG) {printf( "L_BRACKET: %s (%d)\n", yytext, L_BRACKET);} else {return L_BRACKET;}}
|
||||
"]" {if(DEBUG) {printf( "R_BRACKET: %s (%d)\n", yytext, R_BRACKET);} else {return R_BRACKET;}}
|
||||
"{" {if(DEBUG) {printf( "L_BRACE: %s (%d)\n", yytext, L_BRACE);} else {return L_BRACE;}}
|
||||
"}" {if(DEBUG) {printf( "R_BRACE: %s (%d)\n", yytext, R_BRACE);} else {return R_BRACE;}}
|
||||
|
||||
"true" {if(DEBUG) {printf( "C_TRUE: %s (%d)\n", yytext, C_TRUE);} else {return C_TRUE;}}
|
||||
"false" {if(DEBUG) {printf( "C_FALSE: %s (%d)\n", yytext, C_FALSE);} else {return C_FALSE;}}
|
||||
"null" {if(DEBUG) {printf( "C_NULL: %s (%d)\n", yytext, C_NULL);} else {return C_NULL;}}
|
||||
|
||||
{ID} {if(DEBUG) {printf( "ID: %s (%d)\n", yytext, ID);} else {yylval.words = strdup(yytext); return ID;}}
|
||||
|
||||
\n {line_number++; column_number = 1;}
|
||||
\t {column_number++;}
|
||||
" " {column_number++;}
|
||||
. {column_number++; return 1999;}
|
||||
|
||||
%%
|
@ -1,91 +0,0 @@
|
||||
/* Lexical Analyzer with Flex (1.6.0) */
|
||||
/* The Translators - Spring 2025 */
|
||||
|
||||
%option noyywrap
|
||||
%option header-file="flex.h"
|
||||
|
||||
%{
|
||||
#include <stdbool.h>
|
||||
#include "../tmp/grammar.tab.h"
|
||||
#include "../src/symbol_table.h"
|
||||
#ifndef DEBUG
|
||||
#define DEBUG 0
|
||||
#endif
|
||||
extern SymbolTable * cur;
|
||||
extern int tok_flag;
|
||||
extern void incr(int lnum,int cnum, int tok);
|
||||
extern void print_tok(int tok);
|
||||
|
||||
int line_number = 1, column_number = 1;
|
||||
%}
|
||||
|
||||
STARCOM [^\*]|\*+[^\)\*]+
|
||||
PARENCOM [^\)]|[^\*\)]+\)+
|
||||
COMMENT \(\*{STARCOM}*\*\)|\(\*{PARENCOM}*\*\)
|
||||
ID [A-Za-z_][0-9A-Za-z_]*
|
||||
DIGIT [0-9]
|
||||
CHAR \\n|\\t|\\'|[^'\n\t\\]|\\\\
|
||||
SCHAR \\n|\\t|\\\"|[^\"\n\\]
|
||||
|
||||
%%
|
||||
|
||||
"integer" {if(DEBUG) {printf( "T_INTEGER: %s (%d)\n", yytext, T_INTEGER);} else {return T_INTEGER;}}
|
||||
"address" {if(DEBUG) {printf( "T_ADDRESS: %s (%d)\n", yytext, T_ADDRESS);} else {return T_ADDRESS;}}
|
||||
"Boolean" {if(DEBUG) {printf( "T_BOOLEAN: %s (%d)\n", yytext, T_BOOLEAN);} else {return T_BOOLEAN;}}
|
||||
"character" {if(DEBUG) {printf( "T_CHARACTER: %s (%d)\n", yytext, T_CHARACTER);} else {return T_CHARACTER;}}
|
||||
|
||||
"while" {if(DEBUG) {printf( "WHILE: %s (%d)\n", yytext, WHILE);} else {return WHILE;}}
|
||||
"if" {if(DEBUG) {printf( "IF: %s (%d)\n", yytext, IF);} else {return IF;}}
|
||||
"then" {if(DEBUG) {printf( "THEN: %s (%d)\n", yytext, THEN);} else {return THEN;}}
|
||||
"else" {if(DEBUG) {printf( "ELSE: %s (%d)\n", yytext, ELSE);} else {return ELSE;}}
|
||||
"type" {if(DEBUG) {printf( "TYPE: %s (%d)\n", yytext, TYPE);} else {return TYPE;}}
|
||||
"function" {if(DEBUG) {printf( "FUNCTION: %s (%d)\n", yytext, FUNCTION);} else {return FUNCTION;}}
|
||||
"return" {if(DEBUG) {printf( "RETURN: %s (%d)\n", yytext, RETURN);} else {return RETURN;}}
|
||||
"external" {if(DEBUG) {printf( "EXTERNAL: %s (%d)\n", yytext, EXTERNAL);} else {return EXTERNAL;}}
|
||||
"as" {if(DEBUG) {printf( "AS: %s (%d)\n", yytext, AS);} else {return AS;}}
|
||||
|
||||
"release" {if(DEBUG) {printf( "RELEASE: %s (%d)\n", yytext, RELEASE);} else {return RELEASE;}}
|
||||
"reserve" {if(DEBUG) {printf( "RESERVE: %s (%d)\n", yytext, RESERVE);} else {return RESERVE;}}
|
||||
|
||||
"+" {if(DEBUG) {printf( "ADD: %s (%d)\n", yytext, ADD);} else {return ADD;}}
|
||||
"-" {if(DEBUG) {printf( "SUB_OR_NEG: %s (%d)\n", yytext, SUB_OR_NEG);} else {return SUB_OR_NEG;}}
|
||||
"*" {if(DEBUG) {printf( "MUL: %s (%d)\n", yytext, MUL);} else {return MUL;}}
|
||||
"/" {if(DEBUG) {printf( "DIV: %s (%d)\n", yytext, DIV);} else {return DIV;}}
|
||||
"%" {if(DEBUG) {printf( "REM: %s (%d)\n", yytext, REM);} else {return REM;}}
|
||||
"<" {if(DEBUG) {printf( "LESS_THAN: %s (%d)\n", yytext, LESS_THAN);} else {return LESS_THAN;}}
|
||||
"=" {if(DEBUG) {printf( "EQUAL_TO: %s (%d)\n", yytext, EQUAL_TO);} else {return EQUAL_TO;}}
|
||||
":=" {if(DEBUG) {printf( "ASSIGN: %s (%d)\n", yytext, ASSIGN);} else {return ASSIGN;}}
|
||||
"!" {if(DEBUG) {printf( "NOT: %s (%d)\n", yytext, NOT);} else {return NOT;}}
|
||||
"&" {if(DEBUG) {printf( "AND: %s (%d)\n", yytext, AND);} else {return AND;}}
|
||||
"|" {if(DEBUG) {printf( "OR: %s (%d)\n", yytext, OR);} else {return OR;}}
|
||||
"." {if(DEBUG) {printf( "DOT: %s (%d)\n", yytext, DOT);} else {return DOT;}}
|
||||
|
||||
";" {if(DEBUG) {printf( "SEMI_COLON: %s (%d)\n", yytext, SEMI_COLON);} else {return SEMI_COLON;}}
|
||||
":" {if(DEBUG) {printf( "COLON: %s (%d)\n", yytext, COLON);} else {return COLON;}}
|
||||
"," {if(DEBUG) {printf( "COMMA: %s (%d)\n", yytext, COMMA);} else {return COMMA;}}
|
||||
"->" {if(DEBUG) {printf( "ARROW: %s (%d)\n", yytext, ARROW);} else {return ARROW;}}
|
||||
|
||||
{DIGIT}+ {if(DEBUG) {printf( "C_INTEGER: %s (%d)\n", yytext, C_INTEGER);} else {return C_INTEGER;}}
|
||||
'{CHAR}' {if(DEBUG) {printf( "C_CHARACTER: %s (%d)\n", yytext, C_CHARACTER);} else {return C_CHARACTER;}}
|
||||
\"{SCHAR}*\" {if(DEBUG) {printf( "C_STRING: %s (%d)\n", yytext, C_STRING);} else {return C_STRING;}}
|
||||
{COMMENT} {if(DEBUG) {printf( "COMMENT: %s (%d)\n", yytext, COMMENT);} else {/*return COMMENT;*/}}
|
||||
|
||||
"(" {if(DEBUG) {printf( "L_PAREN: %s (%d)\n", yytext, L_PAREN);} else {return L_PAREN;}}
|
||||
")" {if(DEBUG) {printf( "R_PAREN: %s (%d)\n", yytext, R_PAREN);} else {return R_PAREN;}}
|
||||
"[" {if(DEBUG) {printf( "L_BRACKET: %s (%d)\n", yytext, L_BRACKET);} else {return L_BRACKET;}}
|
||||
"]" {if(DEBUG) {printf( "R_BRACKET: %s (%d)\n", yytext, R_BRACKET);} else {return R_BRACKET;}}
|
||||
"{" {if(DEBUG) {printf( "L_BRACE: %s (%d)\n", yytext, L_BRACE);} else {return L_BRACE;}}
|
||||
"}" {if(DEBUG) {printf( "R_BRACE: %s (%d)\n", yytext, R_BRACE);} else {return R_BRACE;}}
|
||||
|
||||
"true" {if(DEBUG) {printf( "C_TRUE: %s (%d)\n", yytext, C_TRUE);} else {return C_TRUE;}}
|
||||
"false" {if(DEBUG) {printf( "C_FALSE: %s (%d)\n", yytext, C_FALSE);} else {return C_FALSE;}}
|
||||
"null" {if(DEBUG) {printf( "C_NULL: %s (%d)\n", yytext, C_NULL);} else {return C_NULL;}}
|
||||
|
||||
{ID} {if(DEBUG) {printf( "ID: %s (%d)\n", yytext, ID);} else {yylval.words = strdup(yytext); return ID;}}
|
||||
|
||||
\n {line_number++; column_number = 1;}
|
||||
\t {column_number++;}
|
||||
" " {column_number++;}
|
||||
. {column_number++; return 1999;}
|
||||
|
||||
%%
|
@ -1,3 +1,6 @@
|
||||
/* Symbol Table */
|
||||
/* The Translators - Spring 2025 */
|
||||
|
||||
#include "symbol_table.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
Reference in New Issue
Block a user