OpenCores
URL https://opencores.org/ocsvn/zipcpu/zipcpu/trunk

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [sw/] [zasm/] [zpp.l] - Diff between revs 16 and 26

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 16 Rev 26
Line 135... Line 135...
[^ \t\n].*$     { BEGIN INNOTDEF; fprintf(stderr, "WARNING! Unexpected characters on IFNDEF line, %s\n", yytext); mark_line(); }
[^ \t\n].*$     { BEGIN INNOTDEF; fprintf(stderr, "WARNING! Unexpected characters on IFNDEF line, %s\n", yytext); mark_line(); }
^"#else"[ \t]*((;|"//").*)?$    { BEGIN NODEF; }
^"#else"[ \t]*((;|"//").*)?$    { BEGIN NODEF; }
^"#else"[ \t]*((;|"//").*)?$            { BEGIN INDEF; }
^"#else"[ \t]*((;|"//").*)?$            { BEGIN INDEF; }
(.*)                    { }
(.*)                    { }
^"#elsif"[ \t]*         { BEGIN NVRDEF; }
^"#elsif"[ \t]*         { BEGIN NVRDEF; }
^"#endif"[ \t]*((;|"//").*)?$   { yy_pop_state(); }
^"#endif"[ \t]*((;|"//").*)?$   { yy_pop_state(); }
^"#endif"[ \t]*"/*"     { BEGIN COMMENT; }
^"#endif"[ \t]*"/*"     { BEGIN COMMENT; }
<*>^"#endif"[ \t]*         { fprintf(stderr, "ERR: Unknown endif!!\n");}
<*>^"#endif"[ \t]*         { fprintf(stderr, "ERR: Unknown endif!!\n");}
^"#struct"[ \t]*        {
^"#struct"[ \t]*        {
                yy_push_state(GETSTRUCTID); structno  = 0; }
                yy_push_state(GETSTRUCTID); structno  = 0; }
 
<*>^"#"{ID}[ \t]*          { fprintf(stderr, "ERR: Unrecognized preprocessor instruction, %s\n", yytext);}
{ID}/[ \t\n;/]  { BEGIN INSTRUCT;
{ID}/[ \t\n;/]  { BEGIN INSTRUCT;
                structid = strdup(yytext);
                structid = strdup(yytext);
                }
                }
{ID}("."{ID})*  {
{ID}("."{ID})*  {
                fprintf(yyout, "\t%s.%s\tequ\t%d", structid, yytext, structno++); }
                fprintf(yyout, "\t%s.%s\tequ\t%d", structid, yytext, structno++); }
Line 158... Line 159...
                else
                else
                        fprintf(yyout, "%s", yytext);
                        fprintf(yyout, "%s", yytext);
        }
        }
<*>[ \t]*"//".*$   { /* Ignore (trailing) comment only lines */ }
<*>[ \t]*"//".*$   { /* Ignore (trailing) comment only lines */ }
<*>[ \t]*";".*$            { /* Ignore (trailing) comment only lines */ }
<*>[ \t]*";".*$            { /* Ignore (trailing) comment only lines */ }
 
<*>"#warning".*$   { fprintf(stderr, "WARNING: %s\n", &yytext[8]); }
 
<*>"#error".*$             { fprintf(stderr, "ERROR: %s\n", &yytext[8]); exit(-1); }
<*>"/*"                    { yy_push_state(COMMENT); }
<*>"/*"                    { yy_push_state(COMMENT); }
<*>[ \t]+          { ECHO; }
<*>[ \t]+          { ECHO; }
<*>\n                      { ECHO; yylineno++; mark_line(); }
<*>\n                      { ECHO; yylineno++; mark_line(); }
        /* <*>.                    { printf("Unmatched \'%c\'\n", yytext[0]); } */
        /* <*>.                    { printf("Unmatched \'%c\'\n", yytext[0]); } */
<>                       { if (end_of_file()) yyterminate(); }
<>       { fprintf(stderr, "Unexpected EOF!  Expecting #endif\n"); }
 
<>               { fprintf(stderr, "Unexpected EOF!  Expecting #endif\n"); }
 
<>       { fprintf(stderr, "Unexpected EOF!  Expecting */\n"); }
 
<>       { fprintf(stderr, "Unexpected EOF!  Expecting #endstruct\n"); }
 
<>       { fprintf(stderr, "Unexpected EOF!  Expecting #struct ID, then #endstruct\n"); }
 
<> { fprintf(stderr, "Unexpected EOF!  Expecting end of line\n"); }
 
 
 
<>       { if (end_of_file()) yyterminate(); }
 
 
%%
%%
 
 
class   SYMTABLE_ENTRY {
class   SYMTABLE_ENTRY {
private:
private:
Line 385... Line 395...
                FILE    *fp = yyout;
                FILE    *fp = yyout;
                if (!fp) fp = stdout;
                if (!fp) fp = stdout;
                fprintf(fp, "#line %d \"%s\"\n", yylineno, m_fname);
                fprintf(fp, "#line %d \"%s\"\n", yylineno, m_fname);
        }
        }
 
 
 
        void    markline(void) {
 
                FILE    *fp = yyout;
 
                if (!fp) fp = stdout;
 
                fprintf(fp, "#line %d\n", yylineno);
 
        }
 
 
        static  void pop(void) {
        static  void pop(void) {
                // fprintf(stderr, "POP! (%s)\n", curbs->m_fname);
                // fprintf(stderr, "POP! (%s)\n", curbs->m_fname);
                if (curbs)
                if (curbs)
                        delete curbs;
                        delete curbs;
        }
        }
Line 399... Line 415...
 
 
int             last_marked_line = -1;
int             last_marked_line = -1;
const char      *last_marked_file = NULL;
const char      *last_marked_file = NULL;
void    mark_line(void) {
void    mark_line(void) {
        if ((yylineno != last_marked_line+1)||(BUFSTACK::curfilename != last_marked_file))
        if ((yylineno != last_marked_line+1)||(BUFSTACK::curfilename != last_marked_file))
                BUFSTACK::curbs->mark();
                if (BUFSTACK::curfilename == last_marked_file)
 
                        BUFSTACK::curbs->markline();
 
                else BUFSTACK::curbs->mark();
        last_marked_line = yylineno;
        last_marked_line = yylineno;
        last_marked_file = BUFSTACK::curfilename;
        last_marked_file = BUFSTACK::curfilename;
}
}
 
 
int     end_of_file(void) {
int     end_of_file(void) {
Line 426... Line 444...
                        mark_line();
                        mark_line();
                        yylex();
                        yylex();
                        // delete       bs;
                        // delete       bs;
                }
                }
        }
        }
 
 
 
        return 0;
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.