Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Duncan White
C-datadec
Commits
5ff65a92
Commit
5ff65a92
authored
Apr 07, 1992
by
dcw
Browse files
added some extra tokens, such as TYPE, EXPORT, GLOBAL, { and }
and added readnextline for export and global reading..
parent
d3ea42c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
lexer.c
View file @
5ff65a92
...
...
@@ -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
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment