'end' as a state
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
%{
|
%{
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "eaxhla.tab.h"
|
#include "eaxhla.tab.h"
|
||||||
|
#include "table.h"
|
||||||
|
|
||||||
char * string_literal_buffer;
|
char * string_literal_buffer;
|
||||||
int string_litral_buffer_size = 0;
|
int string_litral_buffer_size = 0;
|
||||||
@ -22,6 +23,7 @@ uhex [0123456789ABCDEF]
|
|||||||
|
|
||||||
%x IN_COMMENT IN_MULTILINE_COMMENT
|
%x IN_COMMENT IN_MULTILINE_COMMENT
|
||||||
%x IN_STRING
|
%x IN_STRING
|
||||||
|
%x IN_END
|
||||||
|
|
||||||
// XXX: ?!
|
// XXX: ?!
|
||||||
%x IN_DECLARE
|
%x IN_DECLARE
|
||||||
@ -36,18 +38,23 @@ uhex [0123456789ABCDEF]
|
|||||||
|
|
||||||
begin{wsnl}+ { return MYBEGIN; }
|
begin{wsnl}+ { return MYBEGIN; }
|
||||||
|
|
||||||
/* XXX 'end' should be its own state, with proper error handling */
|
|
||||||
program{wsnl}+ { return PROGRAM; }
|
program{wsnl}+ { return PROGRAM; }
|
||||||
end{wsnl}+program{wsnl}+ { return END_PROGRAM; }
|
|
||||||
procedure{wsnl}+ { return PROCEDURE; }
|
procedure{wsnl}+ { return PROCEDURE; }
|
||||||
end{wsnl}+procedure{wsnl}+ { return END_PROCEDURE; }
|
|
||||||
loop{wsnl}+ { return TLOOP; }
|
loop{wsnl}+ { return TLOOP; }
|
||||||
end{wsnl}+loop{wsnl}+ { return END_LOOP; }
|
|
||||||
if{wsnl}+ { return IF; }
|
if{wsnl}+ { return IF; }
|
||||||
then{wsnl}+ { return THEN; }
|
then{wsnl}+ { return THEN; }
|
||||||
end{wsnl}+if{wsnl}+ { return END_IF; }
|
|
||||||
break{wsnl}+ { return BREAK; }
|
break{wsnl}+ { return BREAK; }
|
||||||
|
|
||||||
|
end { BEGIN IN_END; }
|
||||||
|
|
||||||
|
<IN_END>{
|
||||||
|
program { BEGIN INITIAL; return END_PROGRAM; }
|
||||||
|
procedure { BEGIN INITIAL; return END_PROCEDURE; }
|
||||||
|
loop { BEGIN INITIAL; return END_LOOP; }
|
||||||
|
if { BEGIN INITIAL; return END_IF; }
|
||||||
|
{wsnl} { ; }
|
||||||
|
. { yyerror(); }
|
||||||
|
}
|
||||||
|
|
||||||
fast{wsnl}+ { return FAST; }
|
fast{wsnl}+ { return FAST; }
|
||||||
unix{wsnl}+ { return UNIX; }
|
unix{wsnl}+ { return UNIX; }
|
||||||
@ -139,7 +146,7 @@ fastcall{wsnl}+ { return FASTCALL; }
|
|||||||
.|\n { ; }
|
.|\n { ; }
|
||||||
}
|
}
|
||||||
|
|
||||||
{identifier}{wsnl}+ { yylval.strval = strdup(yytext); return IDENTIFIER; }
|
{identifier} { yylval.strval = strdup(yytext); return IDENTIFIER; }
|
||||||
|
|
||||||
. { yyerror(); }
|
. { yyerror(); }
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
%code requires {
|
%code requires {
|
||||||
|
#include "table.h"
|
||||||
// XXX this could be easily squashed later
|
// XXX this could be easily squashed later
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int is_signed;
|
int is_signed;
|
||||||
@ -55,7 +56,7 @@
|
|||||||
%token PROGRAM END_PROGRAM
|
%token PROGRAM END_PROGRAM
|
||||||
%token PROCEDURE END_PROCEDURE
|
%token PROCEDURE END_PROCEDURE
|
||||||
%token TLOOP END_LOOP
|
%token TLOOP END_LOOP
|
||||||
%token IF THEN END_IF
|
%token IF THEN ELSE END_IF
|
||||||
%token BREAK
|
%token BREAK
|
||||||
|
|
||||||
%token<strval> IDENTIFIER
|
%token<strval> IDENTIFIER
|
||||||
@ -147,6 +148,7 @@ loop: TLOOP code END_LOOP
|
|||||||
;
|
;
|
||||||
|
|
||||||
if: IF logic THEN code END_IF
|
if: IF logic THEN code END_IF
|
||||||
|
| IF logic THEN code ELSE code END_IF
|
||||||
;
|
;
|
||||||
|
|
||||||
logic: %empty /* XXX */
|
logic: %empty /* XXX */
|
||||||
|
@ -3,9 +3,10 @@
|
|||||||
#include <tommyds/tommytrie.h>
|
#include <tommyds/tommytrie.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* size_t size; */
|
short size;
|
||||||
/* int * hash; */
|
int * hash;
|
||||||
/* void * data; */
|
void * data;
|
||||||
|
long address;
|
||||||
|
|
||||||
tommy_node node;
|
tommy_node node;
|
||||||
} value_table_t;
|
} value_table_t;
|
||||||
|
Reference in New Issue
Block a user