Compare commits

...

3 Commits

Author SHA1 Message Date
Peter Bieringer 4037f9e524
Merge pull request #100 from cwfoo/lex-yacc-typos
Fix typos in Lex-YACC-HOWTO
2021-02-03 21:28:09 +01:00
Chuan Wei Foo aa77fb82d7
Fix inconsistent use of tabs and spaces 2021-02-04 02:39:34 +08:00
Chuan Wei Foo ae86c97ea6
Fix typos 2021-02-04 02:32:31 +08:00
1 changed files with 4 additions and 4 deletions

View File

@ -422,7 +422,7 @@ output the message passed, but there are smarter things to do. See
the 'Further reading' section at the end.
The function yywrap() can be used to continue reading from another file. It
is called at EOF and you can than open another file, and return 0. Or you
is called at EOF and you can then open another file, and return 0. Or you
can return 1, indicating that this is truly the end. For more about this,
see the 'How do Lex and YACC work internally' chapter.
@ -934,7 +934,7 @@ and integers - but not simultaneously.
Remember that we told YACC previously what type yylval was supposed to be by
defining YYSTYPE. We could conceivably define YYSTYPE to be a union this
way, by YACC has an easier method for doing this: the %union statement.
way, but YACC has an easier method for doing this: the %union statement.
Based on Example 4, we now write the Example 7 YACC grammar. First the
intro:
@ -970,12 +970,12 @@ The Lexer file changes a bit too:
%}
%%
[0-9]+ yylval.number=atoi(yytext); return NUMBER;
heater return TOKHEATER;
heater return TOKHEATER;
heat return TOKHEAT;
on|off yylval.number=!strcmp(yytext,"on"); return STATE;
target return TOKTARGET;
temperature return TOKTEMPERATURE;
[a-z0-9]+ yylval.string=strdup(yytext);return WORD;
[a-z0-9]+ yylval.string=strdup(yytext); return WORD;
\n /* ignore end of line */;
[ \t]+ /* ignore whitespace */;
%%