-
-]AT_LOCATION_IF([
-static YYLTYPE last_yylloc;
-])[
-static int
-yygetc (]AT_LEX_FORMALS[)
-{
- int res = getc (yyin);
- ]AT_USE_LEX_ARGS[;
-]AT_LOCATION_IF([
- last_yylloc = AT_LOC;
- if (res == '\n')
- {
-AT_LALR1_CC_IF(
-[ AT_LOC.end.line++;
- AT_LOC.end.column = 0;],
-[ AT_LOC.last_line++;
- AT_LOC.last_column = 0;])
- }
- else
-AT_LALR1_CC_IF(
-[ AT_LOC.end.column++;],
-[ AT_LOC.last_column++;])
-])[
- return res;
-}
-
-
-static void
-yyungetc (]AT_LEX_PRE_FORMALS[ int c)
-{
- ]AT_USE_LEX_ARGS[;
-]AT_LOCATION_IF([
- /* Wrong when C == `\n'. */
- AT_LOC = last_yylloc;
-])[
- ungetc (c, yyin);
-}
-
-static int
-read_signed_integer (]AT_LEX_FORMALS[)
-{
- int c = yygetc (]AT_LEX_ARGS[);
- int sign = 1;
- int n = 0;
-
- ]AT_USE_LEX_ARGS[;
- if (c == '-')
- {
- c = yygetc (]AT_LEX_ARGS[);
- sign = -1;
- }
-
- while (isdigit (c))
- {
- n = 10 * n + (c - '0');
- c = yygetc (]AT_LEX_ARGS[);
- }
-
- yyungetc (]AT_LEX_PRE_ARGS[ c);
-
- return sign * n;
-}
-
-
-
-/*---------------------------------------------------------------.
-| Lexical analyzer returns an integer on the stack and the token |
-| NUM, or the ASCII character read if not a number. Skips all |
-| blanks and tabs, returns 0 for EOF. |
-`---------------------------------------------------------------*/
-
-static int
-yylex (]AT_LEX_FORMALS[)
-{
- static int init = 1;
- int c;
-
- if (init)
- {
- init = 0;
-]AT_LALR1_CC_IF([],
-[AT_LOCATION_IF([
- AT_LOC.last_column = 0;
- AT_LOC.last_line = 1;
-])])[
- }
-
-]AT_LOCATION_IF([AT_LALR1_CC_IF(
-[ AT_LOC.begin = AT_LOC.end;],
-[ AT_LOC.first_column = AT_LOC.last_column;
- AT_LOC.first_line = AT_LOC.last_line;
-])])[
-
- /* Skip white space. */
- while ((c = yygetc (]AT_LEX_ARGS[)) == ' ' || c == '\t')
- {
-]AT_LOCATION_IF([AT_LALR1_CC_IF(
-[ AT_LOC.begin = AT_LOC.end;],
-[ AT_LOC.first_column = AT_LOC.last_column;
- AT_LOC.first_line = AT_LOC.last_line;
-])])[
- }
-
- /* process numbers */
- if (c == '.' || isdigit (c))
- {
- yyungetc (]AT_LEX_PRE_ARGS[ c);
- ]AT_VAL[.ival = read_signed_integer (]AT_LEX_ARGS[);
- return NUM;
- }
-
- /* Return end-of-file. */
- if (c == EOF)
- return CALC_EOF;
-
- /* Return single chars. */
- return c;
-}