aboutsummaryrefslogtreecommitdiff
path: root/src/lex.l
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-05-13 19:34:35 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2013-05-13 19:34:35 +0000
commit1cc001721ba1923f7e145c74b6b2fa32b36e65da (patch)
tree276d55d1d4e4a25825d7cf3b3352cdbcaad8698e /src/lex.l
parentaa0eaa5bc642167db8cfb5778cf9a0091401a4f3 (diff)
downloadgdbm-1cc001721ba1923f7e145c74b6b2fa32b36e65da.tar.gz
gdbm-1cc001721ba1923f7e145c74b6b2fa32b36e65da.tar.bz2
Add "set" and "define" to the main command table.
* src/gdbmtool.c: Include gram.h (command) <tok>: New member. (command_tab): List "define" and "set". (find_command): Rewrite as command_lookup, with different return type and signature. (run_command): Take struct command * as its first argument. * src/gdbmtool.h (command_lookup): New proto. (run_command): Change signature. (datadef_locate): Rename to datadef_lookup. All uses changed. * src/gram.y: Update. * src/lex.l: Change handling of IDENT rules.
Diffstat (limited to 'src/lex.l')
-rw-r--r--src/lex.l17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/lex.l b/src/lex.l
index 09b5e36..8de9f42 100644
--- a/src/lex.l
+++ b/src/lex.l
@@ -111,8 +111,6 @@ O [0-7]
#.*\n advance_line ();
#.* /* end-of-file comment */;
-def { return T_DEF; }
-set { return T_SET; }
<DEF>off { return T_OFF; }
<DEF>pad { return T_PAD; }
<DEF>0[xX]{X}{X}* { yylval.num = strtoul (yytext, NULL, 16);
@@ -122,8 +120,21 @@ set { return T_SET; }
<DEF>0|{P} { yylval.num = strtoul (yytext, NULL, 10);
return T_NUM; };
+^[ \t]*{IDENT} { if (YYSTATE == DEF)
+ {
+ if (yylval.type = datadef_lookup (yytext))
+ return T_TYPE;
+ }
+ else
+ {
+ return command_lookup (yytext, &yylloc, &yylval.cmd);
+ }
+
+ yylval.string = estrdup (yytext);
+ return T_IDENT;
+ }
{IDENT} { if (YYSTATE == DEF &&
- (yylval.type = datadef_locate (yytext)))
+ (yylval.type = datadef_lookup (yytext)))
return T_TYPE;
else
{

Return to:

Send suggestions and report system problems to the System administrator.