parser eats the example program
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,3 +6,4 @@ eaxhla
|
|||||||
eaxcc
|
eaxcc
|
||||||
.gdb_history
|
.gdb_history
|
||||||
*.pp
|
*.pp
|
||||||
|
library/tommyds/
|
||||||
|
4
Makefile
4
Makefile
@ -62,8 +62,8 @@ bootstrap:
|
|||||||
./library/bootstrap.sh
|
./library/bootstrap.sh
|
||||||
|
|
||||||
test: ${OUT}
|
test: ${OUT}
|
||||||
fcpp -C -LL debug/xop.eax > debug/xop.eax.pp
|
#fcpp -C -LL debug/xop.eax > debug/xop.eax.pp
|
||||||
${WRAP} ./${OUT} debug/xop.eax.pp
|
${WRAP} ./${OUT} debug/xop.eax
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm ${OUT} ${OBJECT} ${GENOBJECT} ${GENSOURCE}
|
-rm ${OUT} ${OBJECT} ${GENOBJECT} ${GENSOURCE}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* It is distributed in the hope that it will be useful or harmful, it really depends... But no warranty what so ever, seriously. See GNU/GPLv3.
|
* It is distributed in the hope that it will be useful or harmful, it really depends... But no warranty what so ever, seriously. See GNU/GPLv3.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xolatile/xtandard.eax>
|
/* #include <xolatile/xtandard.eax> */
|
||||||
|
|
||||||
fast
|
fast
|
||||||
procedure highlight
|
procedure highlight
|
||||||
@ -37,16 +37,16 @@ end procedure
|
|||||||
|
|
||||||
unix
|
unix
|
||||||
program xop
|
program xop
|
||||||
s32 file = -1;
|
s32 file = -1
|
||||||
s32 size = 0;
|
s32 size = 0
|
||||||
s32 offset = 0;
|
s32 offset = 0
|
||||||
|
|
||||||
u8 buffer = NULL;
|
u8 buffer = 0
|
||||||
begin
|
begin
|
||||||
if
|
if
|
||||||
/* argc != 2 */
|
/* argc != 2 */
|
||||||
then
|
then
|
||||||
fatal_failure(1, "xop: xop input")
|
fastcall fatal_failure 1 "xop: xop input"
|
||||||
end if
|
end if
|
||||||
|
|
||||||
fastcall file_open [argv + 1] O_RDONLY
|
fastcall file_open [argv + 1] O_RDONLY
|
||||||
|
@ -1,15 +1,24 @@
|
|||||||
%{
|
%{
|
||||||
|
#include <stdlib.h>
|
||||||
#include "eaxhla.tab.h"
|
#include "eaxhla.tab.h"
|
||||||
|
|
||||||
|
char * string_literal_buffer;
|
||||||
|
int string_litral_buffer_size = 0;
|
||||||
|
int string_litral_buffer_capacity = 128;
|
||||||
|
|
||||||
|
#define YY_USER_INIT \
|
||||||
|
string_literal_buffer = malloc(128);
|
||||||
%}
|
%}
|
||||||
%option noyywrap
|
%option noyywrap
|
||||||
|
|
||||||
identifier [A-Za-z_][A-z0-9_]*
|
identifier [A-Za-z_][A-Za-z0-9_]*
|
||||||
wsnl [ \t\r\v\f\n]
|
wsnl [ \t\r\v\f\n]
|
||||||
|
|
||||||
hex [0123456789abcdef]
|
hex [0123456789abcdef]
|
||||||
uhex [0123456789ABCDEF]
|
uhex [0123456789ABCDEF]
|
||||||
|
|
||||||
%x IN_COMMENT IN_MULTILINE_COMMENT
|
%x IN_COMMENT IN_MULTILINE_COMMENT
|
||||||
|
%x IN_STRING
|
||||||
|
|
||||||
// XXX: ?!
|
// XXX: ?!
|
||||||
%x IN_DECLARE
|
%x IN_DECLARE
|
||||||
@ -49,6 +58,7 @@ unix{wsnl}+ { return UNIX; }
|
|||||||
\$rip{wsnl}+ { return RIP; }
|
\$rip{wsnl}+ { return RIP; }
|
||||||
|
|
||||||
in{wsnl}+ { return TIN; }
|
in{wsnl}+ { return TIN; }
|
||||||
|
\= { return '='; }
|
||||||
|
|
||||||
s8{wsnl}+ { return S8; }
|
s8{wsnl}+ { return S8; }
|
||||||
s16{wsnl}+ { return S16; }
|
s16{wsnl}+ { return S16; }
|
||||||
@ -78,6 +88,25 @@ u64{wsnl}+ { return U64; }
|
|||||||
return LITERAL;
|
return LITERAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
\" { BEGIN IN_STRING; }
|
||||||
|
|
||||||
|
<IN_STRING>{
|
||||||
|
/* XXX: escapes */
|
||||||
|
\" {
|
||||||
|
BEGIN INITIAL;
|
||||||
|
yylval.strval = strdup(string_literal_buffer);
|
||||||
|
return LITERAL;
|
||||||
|
}
|
||||||
|
. {
|
||||||
|
string_litral_buffer_size += yyleng;
|
||||||
|
if (string_litral_buffer_size > string_litral_buffer_capacity) {
|
||||||
|
string_litral_buffer_capacity *= 2;
|
||||||
|
realloc(string_literal_buffer, string_litral_buffer_capacity);
|
||||||
|
}
|
||||||
|
memcpy(string_literal_buffer + string_litral_buffer_size, yytext, yyleng);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
xor{wsnl}+ { return TXOR; }
|
xor{wsnl}+ { return TXOR; }
|
||||||
inc{wsnl}+ { return TINC; }
|
inc{wsnl}+ { return TINC; }
|
||||||
|
|
||||||
@ -106,6 +135,8 @@ fastcall{wsnl}+ { return FASTCALL; }
|
|||||||
|
|
||||||
{identifier}{wsnl}+ { yylval.strval = strdup(yytext); return IDENTIFIER; }
|
{identifier}{wsnl}+ { yylval.strval = strdup(yytext); return IDENTIFIER; }
|
||||||
|
|
||||||
|
. { yyerror(); }
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
void set_state(int state) {
|
void set_state(int state) {
|
||||||
@ -121,4 +152,6 @@ void yyfree_leftovers(void) {
|
|||||||
for (size_t i = 0; i < yy_buffer_stack_max; i++) {
|
for (size_t i = 0; i < yy_buffer_stack_max; i++) {
|
||||||
free(yy_buffer_stack[i]);
|
free(yy_buffer_stack[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(string_literal_buffer);
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,7 @@ declaration_section: %empty
|
|||||||
;
|
;
|
||||||
|
|
||||||
declaration: origin type IDENTIFIER { $2.name = $3; /* add_var($1); */ free($3); }
|
declaration: origin type IDENTIFIER { $2.name = $3; /* add_var($1); */ free($3); }
|
||||||
|
| origin type IDENTIFIER '=' LITERAL { $2.name = $3; /* add_var($1); */ free($3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
origin: %empty
|
origin: %empty
|
||||||
|
Reference in New Issue
Block a user