Commit 5ff65a92 authored by dcw's avatar dcw
Browse files

added some extra tokens, such as TYPE, EXPORT, GLOBAL, { and }

and added readnextline for export and global reading..
parent d3ea42c6
......@@ -11,7 +11,7 @@
******* Tokens:
*
* tERROR tEOF tSEMI tID tEQ tOR tOPENBR tCOMMA tCLOSEBR
* tSTR tNUM
* tSTR tNUM tEXPORT tGLOBAL tOPENCURLY tCLOSECURLY tTYPE
*/
......@@ -23,7 +23,8 @@
#ifdef DEBUGGING
static char *tokenname[] = {
"tERROR", "tEOF", "tSEMI", "tID", "tEQ", "tOR", "tOPENBR",
"tCOMMA", "tCLOSEBR", "tSTR", "tNUM"
"tCOMMA", "tCLOSEBR", "tSTR", "tNUM", "tEXPORT", "tGLOBAL",
"tOPENCURLY", "tCLOSECURLY", "tTYPE"
};
#endif
......@@ -90,6 +91,8 @@ TOKEN nexttok()
{
case EOF: curtok = tEOF; break;
case ';': curtok = tSEMI; break;
case '{': curtok = tOPENCURLY; break;
case '}': curtok = tCLOSECURLY; break;
case '(': curtok = tOPENBR; break;
case ')': curtok = tCLOSEBR; break;
case ',': curtok = tCOMMA; break;
......@@ -124,6 +127,16 @@ TOKEN nexttok()
while( pos<MAXIDSIZE )
lexidval[pos++] = '\0';
strcpy( curid, lexidval );
if( streq( curid, "EXPORT" ) )
{
curtok = tEXPORT;
} else if( streq( curid, "GLOBAL" ) )
{
curtok = tGLOBAL;
} else if( streq( curid, "TYPE" ) )
{
curtok = tTYPE;
}
} else if( isdigit( c ) )
{
int t;
......@@ -147,3 +160,15 @@ printf( "returning token %s\n", tokenname[ curtok ] );
#endif
return curtok;
}
BOOL readnextline( line ) char *line;
{
int c;
char *s = line;
while( (c=getc(lexfile)) != EOF && c != '\n' ) *s++ = c;
*s = '\0';
lineno++;
return c != EOF;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment