From 5f8c1d144b3c91f2c4ba75d709a74d83c1f3d5a0 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sat, 26 Aug 2023 13:44:07 +0200 Subject: ast and cleanup --- grammar.y | 99 --------------------------------------------------------------- 1 file changed, 99 deletions(-) delete mode 100644 grammar.y (limited to 'grammar.y') diff --git a/grammar.y b/grammar.y deleted file mode 100644 index a37dae6..0000000 --- a/grammar.y +++ /dev/null @@ -1,99 +0,0 @@ -%{ -#include - -#include "ast.c" - -extern FILE *yyin; - -extern int yylex(); -extern void yyerror(); - -ast_node* yyast = NULL; -%} - -%define parse.error verbose - -%union { - char* string; - int number; - ast_node* node; -} - -%token OPERATOR_PLUS -%token OPERATOR_MINUS -%token ASSIGN - -%token FUNCTION -%token IF -%token ELSE -%token RETURN -%token CONST -%token VAR - -%token TYPE_INTEGER -%token TYPE_STRING -%token TYPE_VOID - -%token PARENTHESIS_LEFT -%token PARENTHESIS_RIGHT -%token BRACE_LEFT -%token BRACE_RIGHT -%token BRACKET_LEFT -%token BRACKET_RIGHT - -%token COMMA; -%token COLON; - -%token NUMBER; -%token IDENTIFIER -%token COMMENT; - -%token END_OF_LINE; - -%type program -%type function -%type arguments -%type argument -%type return_type -%type variable_type -%type statements -%type statement -%type expression - -%start program - -%% -program: - statement END_OF_LINE - | program program { $$ = create_program_node($1, $2); } - -variable_type: - TYPE_INTEGER { printf("variable_type:: %s\n", $1); $$ = create_type_node($1); } - | TYPE_STRING { $$ = create_type_node($1); } - - -statements: - statement - | statements END_OF_LINE statement - -statement: - // const henshin: integer = 2 - CONST IDENTIFIER COLON variable_type ASSIGN expression { printf("$1: %s -- $2: %s -- $3: %s -- $4: %s -- $5: %s -- $6: %s\n", $1, $2, $3, "4", $5, "6"); } - - -expression: - NUMBER -%% - -void main (int argc, char **argv) -{ - #ifdef YYDEBUG - yydebug = 1; - #endif - - //henshin_lex(); - yyin = fopen(argv[1], "r"); - yyparse(); - - printf("%s", yyast); -} -- cgit v1.2.3