URL
https://opencores.org/ocsvn/zipcpu/zipcpu/trunk
Subversion Repositories zipcpu
Compare Revisions
- This comparison shows the changes necessary to convert path
/zipcpu/trunk
- from Rev 53 to Rev 52
- ↔ Reverse comparison
Rev 53 → Rev 52
/sw/zasm/zpp.l
71,7 → 71,7
const char *stb_getdefn(const char *str); |
%} |
%x DEF DFA DFV DFV_EOL INDEF IFDEFV INNOTDEF NODEF NVRDEF COMMENT INSTRUCT |
%x INDEF_EOL INNOTDEF_EOL GETSTRUCTID NVRDEF_EOL DONTDEF |
%x INDEF_EOL INNOTDEF_EOL GETSTRUCTID |
%option noyywrap |
%option stack |
ID [_:A-Za-z][_:A-Za-z0-9]* |
79,9 → 79,9
|
%% |
<COMMENT>"*/" { yy_pop_state(); } |
<COMMENT>[^*\n]+ { /* Ignore comments */ } |
<COMMENT>[^*]+ { /* Ignore comments */ } |
<COMMENT>"*"+[^/] { /* Ignore comments */ } |
<INITIAL,INDEF>^"#include"[ \t]+\"[^\n\"]+\" { |
<INITIAL,INDEF>^"#include"[ \t]+\"[^\"]+\" { |
char *ptr = &yytext[9], *start, *end, *str; |
while(isspace(*ptr)) |
ptr++; |
102,7 → 102,7
BEGIN DFV; |
} |
<DEF>{IDDOT}/[(] { stb_define(yytext); BEGIN DFA; } |
<DFA>"("[^)\n]+")" { |
<DFA>"("[^)]+")" { |
/* Process macro arguments */ |
stb_args(yytext); |
BEGIN DFV; |
154,11 → 154,11
// fprintf(stderr, "C: Adding to macro %s\n", yytext); |
stb_macro(yytext); |
} |
<DFV>[0-7]+[oO] {/* Get any octal constants */ |
<DFV>[0-7]+[oO] {/* Get any hexadecimal constants */ |
// fprintf(stderr, "D: Adding to macro %s\n", yytext); |
stb_macro(yytext); |
} |
<DFV>[0-9]+ {/* Get any decimal constants */ |
<DFV>[0-9]+ {/* Get any hexadecimal constants */ |
// fprintf(stderr, "E: Adding to macro %s\n", yytext); |
stb_macro(yytext); |
} |
169,30 → 169,13
fprintf(yyout, "\n"); mark_line(); yylineno++; |
stb_macro("\n"); |
} |
<INNOTDEF,NODEF,NVRDEF>^"#define".*$ { yy_push_state(DONTDEF); } |
<DONTDEF>"\\"[ \t]*((;"//").*)?\n {/* Continue onto next line */ |
fprintf(yyout, "\n"); mark_line(); yylineno++; } |
<DONTDEF>[a-zA-Z0-9_,.()]* { } |
<DONTDEF>[ \t]* { } |
<DONTDEF>((;|"//").*)?$ { yy_pop_state(); } |
<DONTDEF>"\\"[ \t]*((;|"//").*)?\n {/* Continue onto next line */ |
fprintf(yyout, "\n"); mark_line(); yylineno++; } |
<INITIAL,INDEF>^[ \t]+.[dD][aA][tT][aA]? { fprintf(yyout, "\tWORD"); } |
<INITIAL,INDEF>^"#defcont"[ \t]+ { |
yy_push_state(DFV); } |
<INITIAL,INDEF>^"#ifdef"[ \t]* { ndef = 0; |
yy_push_state(IFDEFV); } |
<INITIAL,INDEF>^"#ifndef"[ \t]* { ndef = 1; |
yy_push_state(IFDEFV); } |
<INNOTDEF,NODEF,NVRDEF>^"#ifdef"[ \t]* { ndef = 2; |
yy_push_state(IFDEFV); } |
<INNOTDEF,NODEF,NVRDEF>^"#ifndef"[ \t]* { ndef = 2; |
yy_push_state(IFDEFV); } |
<INITIAL,INDEF>^"#defcont"[ \t]+ { yy_push_state(DFV); } |
<INITIAL,INDEF>^"#ifdef"[ \t]* { ndef = 0; yy_push_state(IFDEFV); } |
<INITIAL,INDEF>^"#ifndef"[ \t]* { ndef = 1; yy_push_state(IFDEFV); } |
<IFDEFV>{IDDOT} { |
bool known = stb_isdefined(yytext); |
if (ndef == 2) { |
BEGIN NVRDEF_EOL; |
} else if ( ((known)&&(ndef==0)) || ((!known)&&(ndef!=0)) ) { |
if ( ((known)&&(ndef==0)) || ((!known)&&(ndef!=0)) ) { |
BEGIN INDEF_EOL; |
} else { |
BEGIN INNOTDEF_EOL; |
206,26 → 189,18
<INDEF_EOL>(;|"//").*$ { BEGIN INDEF; } |
<INNOTDEF_EOL>[ \t]*$ { BEGIN INNOTDEF; } |
<INNOTDEF_EOL>(;|"//").*$ { BEGIN INNOTDEF; } |
<NVRDEF_EOL>[ \t]*$ { BEGIN NVRDEF; } |
<NVRDEF_EOL>(;|"//").*$ { BEGIN NVRDEF; } |
<NVRDEF_EOL>[^ \t\n].*$ { BEGIN INDEF; mark_line(); } |
<INNOTDEF_EOL>[^ \t\n].*$ { BEGIN INNOTDEF; mark_line(); } |
<INDEF_EOL>[^ \t\n].*$ { BEGIN INDEF; fprintf(stderr, "WARNING! Unexpected characters on IFDEF line, \'%s\'\n", yytext); mark_line(); } |
<INNOTDEF_EOL>[^ \t\n].*$ { BEGIN INNOTDEF; fprintf(stderr, "WARNING! Unexpected characters on IFNDEF line, %s\n", yytext); mark_line(); } |
<INDEF,NVRDEF>^"#else"[ \t]*((;|"//").*)?$ { BEGIN NODEF; } |
<INNOTDEF>^"#else"[ \t]*((;|"//").*)?$ { BEGIN INDEF; } |
<INNOTDEF,NVRDEF,NODEF>^[^#\n]([^\n]*)$ { /* Skip text */ } |
<INNOTDEF>(.*) { } |
<INDEF>^"#elsif"[ \t]* { BEGIN NVRDEF; } |
<NVRDEF,NODEF,INDEF,INNOTDEF>^"#endif"[ \t]*((;|"//").*)?$ { |
yy_pop_state(); } |
<NVRDEF,NODEF,INDEF,INNOTDEF>^"#endif"[ \t]*((;|"//").*)?$ { yy_pop_state(); } |
<NVRDEF,NODEF,INDEF,INNOTDEF>^"#endif"[ \t]*"/*" { BEGIN COMMENT; } |
<NVRDEF,NODEF,INDEF,INNOTDEF>^"#endif" { yy_pop_state(); } |
<*>^"#ifdef"[ \t]* { fprintf(stderr, "ERR: Line %d, Unknown ifdef!! (state = %d)\n", yylineno, YYSTATE);} |
<*>^"#else"[ \t]* { fprintf(stderr, "ERR: Line %d, Unknown else!! (state = %d)\n", yylineno, YYSTATE);} |
<*>^"#endif"[ \t]* { fprintf(stderr, "ERR: Line %d, Unknown endif!! (state = %d)\n", yylineno, YYSTATE);} |
<INITIAL,INDEF>^"#struct"[ \t]* { yy_push_state(GETSTRUCTID); structno = 0; } |
<*>^"#"{ID}[ \t]* { |
fprintf(stderr, "ERR: Line %d, unrecognized preprocessor instruction, \'%s\' (state = %d)\n", |
yylineno, yytext, YYSTATE); |
} |
<*>^"#endif"[ \t]* { fprintf(stderr, "ERR: Unknown endif!!\n");} |
<INITIAL,INDEF>^"#struct"[ \t]* { |
yy_push_state(GETSTRUCTID); structno = 0; } |
<*>^"#"{ID}[ \t]* { fprintf(stderr, "ERR: Unrecognized preprocessor instruction, %s\n", yytext);} |
<GETSTRUCTID>{ID}/[ \t\n;/] { BEGIN INSTRUCT; |
structid = strdup(yytext); |
} |
235,6 → 210,7
/* Not yet: ^"#struct"[ \t]* {} */ |
/* Not yet: ^"#endstruct"[ \t]* {} */ |
/* Not yet: ^"#seg"[ \t]* {} */ |
<NODEF,NVRDEF>.* { /* Ignore everything in these states*/ } |
<INITIAL,INDEF>{ID}/[^(] { |
if (stb_isdefined(yytext)) |
fprintf(yyout, "%s", stb_getdefn(yytext)); |
269,13 → 245,13
<*>[ \t]+ { ECHO; } |
<*>\n { ECHO; yylineno++; mark_line(); } |
/* <*>. { printf("Unmatched \'%c\'\n", yytext[0]); } */ |
<NVRDEF,NODEF,INDEF,INNOTDEF><<EOF>> { fprintf(stderr, "Unexpected EOF! Expecting #endif\n"); yyterminate(); } |
<IFDEFV><<EOF>> { fprintf(stderr, "Unexpected EOF! Expecting #endif\n"); yyterminate(); } |
<COMMENT><<EOF>> { fprintf(stderr, "Unexpected EOF! Expecting */\n"); yyterminate(); } |
<INSTRUCT><<EOF>> { fprintf(stderr, "Unexpected EOF! Expecting #endstruct\n"); yyterminate(); } |
<GETSTRUCTID><<EOF>> { fprintf(stderr, "Unexpected EOF! Expecting #struct ID, then #endstruct\n"); yyterminate(); } |
<DFA,DFV,DFV_EOL><<EOF>> { fprintf(stderr, "Unexpected EOF! Expecting end of line\n"); yyterminate(); } |
<INDEF_EOL,INNOTDEF_EOL><<EOF> { fprintf(stderr, "Unexpected EOF Expecting end of line, then #endif\n"); yyterminate(); } |
<NVRDEF,NODEF,INDEF,INNOTDEF><<EOF>> { fprintf(stderr, "Unexpected EOF! Expecting #endif\n"); } |
<IFDEFV><<EOF>> { fprintf(stderr, "Unexpected EOF! Expecting #endif\n"); } |
<COMMENT><<EOF>> { fprintf(stderr, "Unexpected EOF! Expecting */\n"); } |
<INSTRUCT><<EOF>> { fprintf(stderr, "Unexpected EOF! Expecting #endstruct\n"); } |
<GETSTRUCTID><<EOF>> { fprintf(stderr, "Unexpected EOF! Expecting #struct ID, then #endstruct\n"); } |
<DFA,DFV,DFV_EOL><<EOF>> { fprintf(stderr, "Unexpected EOF! Expecting end of line\n"); } |
<INDEF_EOL,INNOTDEF_EOL><<EOF> { fprintf(stderr, "Unexpected EOF Expecting end of line, then #endif\n"); } |
<INITIAL><<EOF>> { if (end_of_file()) yyterminate(); } |
|
%% |
700,13 → 676,13
char *pathcpy = new char[strlen(pathptr)+8192]; |
strcpy(pathcpy, pathptr); |
|
// fprintf(stderr, "ZIPINC := %s\n", pathptr); |
fprintf(stderr, "ZIPINC := %s\n", pathptr); |
dptr = pathptr; |
while((!m_fp)&&(NULL != (colonp = strchr(dptr, ':')))) { |
strncpy(pathcpy, dptr, colonp-pathptr); |
strcat(pathcpy, "/"); |
strcat(pathcpy, fname); |
// fprintf(stderr, "Looking for include file, %s\n", pathcpy); |
fprintf(stderr, "Looking for include file, %s\n", pathcpy); |
if (access(fname, R_OK)==0) |
m_fp = fopen(pathcpy, "r"); |
dptr = colonp+1; |
714,7 → 690,7
strcpy(pathcpy, dptr); |
strcat(pathcpy, "/"); |
strcat(pathcpy, fname); |
// fprintf(stderr, "Looking for include file, %s\n", pathcpy); |
fprintf(stderr, "Looking for include file, %s\n", pathcpy); |
m_fp = fopen(pathcpy, "r"); |
} if (!m_fp) { |
fprintf(stderr, "Cannot open %s\n", fname); |
813,5 → 789,4
|
return 0; |
} |
// <NODEF,NVRDEF>.* { fprintf(stderr, "Ignoring everything, line %d, \'%s\'\n", yylineno, yytext); /* Ignore everything in these states*/ } |
|