Files
compiler-the-translators/grammar.y
2025-02-26 12:52:29 -05:00

74 lines
1.5 KiB
Plaintext

/* Syntax Analyzer with Bison (3.8.1) */
/* (referenced Bison manual for file boilerplate [3.1]) */
// Prologue
%{
#include <stdio.h>
#include "symbol_table.c"
%}
%token ID 101
%token T_INTEGER 201
%token T_ADDRESS 202
%token T_BOOLEAN 203
%token T_CHARACTER 204
%token 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 ADD 601
%token SUB_OR_NEG 602
%token MUL 603
%token DIV 604
%token REM 605
%token LESS_THAN 606
%token EQUAL_TO 607
%token ASSIGN 608
%token NOT 609
%token AND 610
%token OR 611
%token DOT 612
%token RESERVE 613
%token RELEASE 614
%token COMMENT 700
%%
start: /*empty for now*/
;
// B : '{'{CreateScope(cur,line,column)} E '}'; //Braced Expressions can have braces removed to get regular expressions
// D : '[' l ']'; //Declaration Lists Brackets can be taken out to get a list of Declarations
// E : Maybe_D U; //An expression can start with an optional D followed by an undeclared segment
// Maybe_D : D
// | ; //Either D or not
//l : A ';' l;
// | ; //a declaration list can either be empty or be an assignment followed by a semi-colon and another list
%%
int main() {
return yyparse();
}