1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #include <libpspp/message.h>
28 #include <libpspp/alloc.h>
29 #include <libpspp/assertion.h>
30 #include <language/command.h>
31 #include <libpspp/message.h>
32 #include <libpspp/magic.h>
33 #include <data/settings.h>
34 #include <libpspp/getl.h>
35 #include <libpspp/str.h>
40 #define _(msgid) gettext (msgid)
41 #define N_(msgid) msgid
49 struct string line_buffer;
51 struct source_stream *ss;
53 int token; /* Current token. */
54 double tokval; /* T_POS_NUM, T_NEG_NUM: the token's value. */
56 char tokid [LONG_NAME_LEN + 1]; /* T_ID: the identifier. */
58 struct string tokstr; /* T_ID, T_STRING: token string value.
59 For T_ID, this is not truncated as is
62 char *prog; /* Pointer to next token in line_buffer. */
63 bool dot; /* True only if this line ends with a terminal dot. */
65 int put_token ; /* If nonzero, next token returned by lex_get().
66 Used only in exceptional circumstances. */
68 struct string put_tokstr;
73 static int parse_id (struct lexer *);
75 /* How a string represents its contents. */
78 CHARACTER_STRING, /* Characters. */
79 BINARY_STRING, /* Binary digits. */
80 OCTAL_STRING, /* Octal digits. */
81 HEX_STRING /* Hexadecimal digits. */
84 static int parse_string (struct lexer *, enum string_type);
87 static void dump_token (struct lexer *);
92 /* Initializes the lexer. */
94 lex_create (struct source_stream *ss)
96 struct lexer *lexer = xzalloc (sizeof (*lexer));
98 ds_init_empty (&lexer->tokstr);
99 ds_init_empty (&lexer->put_tokstr);
100 ds_init_empty (&lexer->line_buffer);
106 struct source_stream *
107 lex_get_source_stream (const struct lexer *lex)
114 lex_destroy (struct lexer *lexer)
118 ds_destroy (&lexer->put_tokstr);
119 ds_destroy (&lexer->tokstr);
120 ds_destroy (&lexer->line_buffer);
127 /* Common functions. */
129 /* Copies put_token, lexer->put_tokstr, put_tokval into token, tokstr,
130 tokval, respectively, and sets tokid appropriately. */
132 restore_token (struct lexer *lexer)
134 assert (lexer->put_token != 0);
135 lexer->token = lexer->put_token;
136 ds_assign_string (&lexer->tokstr, &lexer->put_tokstr);
137 str_copy_trunc (lexer->tokid, sizeof lexer->tokid, ds_cstr (&lexer->tokstr));
138 lexer->tokval = lexer->put_tokval;
139 lexer->put_token = 0;
142 /* Copies token, tokstr, lexer->tokval into lexer->put_token, put_tokstr,
143 put_lexer->tokval respectively. */
145 save_token (struct lexer *lexer)
147 lexer->put_token = lexer->token;
148 ds_assign_string (&lexer->put_tokstr, &lexer->tokstr);
149 lexer->put_tokval = lexer->tokval;
152 /* Parses a single token, setting appropriate global variables to
153 indicate the token's attributes. */
155 lex_get (struct lexer *lexer)
160 if (NULL == lexer->prog && ! lex_get_line (lexer) )
162 lexer->token = T_STOP;
166 /* If a token was pushed ahead, return it. */
167 if (lexer->put_token)
169 restore_token (lexer);
178 /* Skip whitespace. */
179 while (isspace ((unsigned char) *lexer->prog))
194 else if (!lex_get_line (lexer))
197 lexer->token = T_STOP;
204 if (lexer->put_token)
206 restore_token (lexer);
215 /* Actually parse the token. */
216 ds_clear (&lexer->tokstr);
218 switch (*lexer->prog)
221 case '0': case '1': case '2': case '3': case '4':
222 case '5': case '6': case '7': case '8': case '9':
226 /* `-' can introduce a negative number, or it can be a
227 token by itself. If it is not followed by a digit or a
228 decimal point, it is definitely not a number.
229 Otherwise, it might be either, but most of the time we
230 want it as a number. When the syntax calls for a `-'
231 token, lex_negative_to_dash() must be used to break
232 negative numbers into two tokens. */
233 if (*lexer->prog == '-')
235 ds_put_char (&lexer->tokstr, *lexer->prog++);
236 while (isspace ((unsigned char) *lexer->prog))
239 if (!isdigit ((unsigned char) *lexer->prog) && *lexer->prog != '.')
244 lexer->token = T_NEG_NUM;
247 lexer->token = T_POS_NUM;
249 /* Parse the number, copying it into tokstr. */
250 while (isdigit ((unsigned char) *lexer->prog))
251 ds_put_char (&lexer->tokstr, *lexer->prog++);
252 if (*lexer->prog == '.')
254 ds_put_char (&lexer->tokstr, *lexer->prog++);
255 while (isdigit ((unsigned char) *lexer->prog))
256 ds_put_char (&lexer->tokstr, *lexer->prog++);
258 if (*lexer->prog == 'e' || *lexer->prog == 'E')
260 ds_put_char (&lexer->tokstr, *lexer->prog++);
261 if (*lexer->prog == '+' || *lexer->prog == '-')
262 ds_put_char (&lexer->tokstr, *lexer->prog++);
263 while (isdigit ((unsigned char) *lexer->prog))
264 ds_put_char (&lexer->tokstr, *lexer->prog++);
267 /* Parse as floating point. */
268 lexer->tokval = strtod (ds_cstr (&lexer->tokstr), &tail);
271 msg (SE, _("%s does not form a valid number."),
272 ds_cstr (&lexer->tokstr));
275 ds_clear (&lexer->tokstr);
276 ds_put_char (&lexer->tokstr, '0');
283 lexer->token = parse_string (lexer, CHARACTER_STRING);
286 case '(': case ')': case ',': case '=': case '+': case '/':
287 lexer->token = *lexer->prog++;
291 if (*++lexer->prog == '*')
294 lexer->token = T_EXP;
301 if (*++lexer->prog == '=')
306 else if (*lexer->prog == '>')
316 if (*++lexer->prog == '=')
326 if (*++lexer->prog == '=')
332 lexer->token = T_NOT;
337 lexer->token = T_AND;
346 if (lexer->prog[1] == '\'' || lexer->prog[1] == '"')
347 lexer->token = parse_string (lexer, BINARY_STRING);
349 lexer->token = parse_id (lexer);
353 if (lexer->prog[1] == '\'' || lexer->prog[1] == '"')
354 lexer->token = parse_string (lexer, OCTAL_STRING);
356 lexer->token = parse_id (lexer);
360 if (lexer->prog[1] == '\'' || lexer->prog[1] == '"')
361 lexer->token = parse_string (lexer, HEX_STRING);
363 lexer->token = parse_id (lexer);
367 if (lex_is_id1 (*lexer->prog))
369 lexer->token = parse_id (lexer);
374 if (isgraph ((unsigned char) *lexer->prog))
375 msg (SE, _("Bad character in input: `%c'."), *lexer->prog++);
377 msg (SE, _("Bad character in input: `\\%o'."), *lexer->prog++);
389 /* Parses an identifier at the current position into tokid and
391 Returns the correct token type. */
393 parse_id (struct lexer *lexer)
395 struct substring rest_of_line
396 = ss_substr (ds_ss (&lexer->line_buffer),
397 ds_pointer_to_position (&lexer->line_buffer, lexer->prog),
399 struct substring id = ss_head (rest_of_line,
400 lex_id_get_length (rest_of_line));
401 lexer->prog += ss_length (id);
403 ds_assign_substring (&lexer->tokstr, id);
404 str_copy_trunc (lexer->tokid, sizeof lexer->tokid, ds_cstr (&lexer->tokstr));
405 return lex_id_to_token (id);
408 /* Reports an error to the effect that subcommand SBC may only be
411 lex_sbc_only_once (const char *sbc)
413 msg (SE, _("Subcommand %s may only be specified once."), sbc);
416 /* Reports an error to the effect that subcommand SBC is
419 lex_sbc_missing (struct lexer *lexer, const char *sbc)
421 lex_error (lexer, _("missing required subcommand %s"), sbc);
424 /* Prints a syntax error message containing the current token and
425 given message MESSAGE (if non-null). */
427 lex_error (struct lexer *lexer, const char *message, ...)
432 token_rep = lex_token_representation (lexer);
433 if (lexer->token == T_STOP)
434 strcpy (where, "end of file");
435 else if (lexer->token == '.')
436 strcpy (where, "end of command");
438 snprintf (where, sizeof where, "`%s'", token_rep);
446 va_start (args, message);
447 vsnprintf (buf, 1024, message, args);
450 msg (SE, _("Syntax error %s at %s."), buf, where);
453 msg (SE, _("Syntax error at %s."), where);
456 /* Checks that we're at end of command.
457 If so, returns a successful command completion code.
458 If not, flags a syntax error and returns an error command
461 lex_end_of_command (struct lexer *lexer)
463 if (lexer->token != '.')
465 lex_error (lexer, _("expecting end of command"));
472 /* Token testing functions. */
474 /* Returns true if the current token is a number. */
476 lex_is_number (struct lexer *lexer)
478 return lexer->token == T_POS_NUM || lexer->token == T_NEG_NUM;
481 /* Returns the value of the current token, which must be a
482 floating point number. */
484 lex_number (struct lexer *lexer)
486 assert (lex_is_number (lexer));
487 return lexer->tokval;
490 /* Returns true iff the current token is an integer. */
492 lex_is_integer (struct lexer *lexer)
494 return (lex_is_number (lexer)
495 && lexer->tokval != NOT_LONG
496 && lexer->tokval >= LONG_MIN
497 && lexer->tokval <= LONG_MAX
498 && floor (lexer->tokval) == lexer->tokval);
501 /* Returns the value of the current token, which must be an
504 lex_integer (struct lexer *lexer)
506 assert (lex_is_integer (lexer));
507 return lexer->tokval;
510 /* Token matching functions. */
512 /* If TOK is the current token, skips it and returns true
513 Otherwise, returns false. */
515 lex_match (struct lexer *lexer, int t)
517 if (lexer->token == t)
526 /* If the current token is the identifier S, skips it and returns
527 true. The identifier may be abbreviated to its first three
529 Otherwise, returns false. */
531 lex_match_id (struct lexer *lexer, const char *s)
533 if (lexer->token == T_ID
534 && lex_id_match (ss_cstr (s), ss_cstr (lexer->tokid)))
543 /* If the current token is integer N, skips it and returns true.
544 Otherwise, returns false. */
546 lex_match_int (struct lexer *lexer, int x)
548 if (lex_is_integer (lexer) && lex_integer (lexer) == x)
557 /* Forced matches. */
559 /* If this token is identifier S, fetches the next token and returns
561 Otherwise, reports an error and returns zero. */
563 lex_force_match_id (struct lexer *lexer, const char *s)
565 if (lex_match_id (lexer, s))
569 lex_error (lexer, _("expecting `%s'"), s);
574 /* If the current token is T, skips the token. Otherwise, reports an
575 error and returns from the current function with return value false. */
577 lex_force_match (struct lexer *lexer, int t)
579 if (lexer->token == t)
586 lex_error (lexer, _("expecting `%s'"), lex_token_name (t));
591 /* If this token is a string, does nothing and returns true.
592 Otherwise, reports an error and returns false. */
594 lex_force_string (struct lexer *lexer)
596 if (lexer->token == T_STRING)
600 lex_error (lexer, _("expecting string"));
605 /* If this token is an integer, does nothing and returns true.
606 Otherwise, reports an error and returns false. */
608 lex_force_int (struct lexer *lexer)
610 if (lex_is_integer (lexer))
614 lex_error (lexer, _("expecting integer"));
619 /* If this token is a number, does nothing and returns true.
620 Otherwise, reports an error and returns false. */
622 lex_force_num (struct lexer *lexer)
624 if (lex_is_number (lexer))
627 lex_error (lexer, _("expecting number"));
631 /* If this token is an identifier, does nothing and returns true.
632 Otherwise, reports an error and returns false. */
634 lex_force_id (struct lexer *lexer)
636 if (lexer->token == T_ID)
639 lex_error (lexer, _("expecting identifier"));
643 /* Weird token functions. */
645 /* Returns the first character of the next token, except that if the
646 next token is not an identifier, the character returned will not be
647 a character that can begin an identifier. Specifically, the
648 hexstring lead-in X' causes lookahead() to return '. Note that an
649 alphanumeric return value doesn't guarantee an ID token, it could
650 also be a reserved-word token. */
652 lex_look_ahead (struct lexer *lexer)
654 if (lexer->put_token)
655 return lexer->put_token;
659 if (NULL == lexer->prog && ! lex_get_line (lexer) )
664 while (isspace ((unsigned char) *lexer->prog))
671 else if (!lex_get_line (lexer))
674 if (lexer->put_token)
675 return lexer->put_token;
678 if ((toupper ((unsigned char) *lexer->prog) == 'X'
679 || toupper ((unsigned char) *lexer->prog) == 'B'
680 || toupper ((unsigned char) *lexer->prog) == 'O')
681 && (lexer->prog[1] == '\'' || lexer->prog[1] == '"'))
688 /* Makes the current token become the next token to be read; the
689 current token is set to T. */
691 lex_put_back (struct lexer *lexer, int t)
697 /* Makes the current token become the next token to be read; the
698 current token is set to the identifier ID. */
700 lex_put_back_id (struct lexer *lexer, const char *id)
702 assert (lex_id_to_token (ss_cstr (id)) == T_ID);
705 ds_assign_cstr (&lexer->tokstr, id);
706 str_copy_trunc (lexer->tokid, sizeof lexer->tokid, ds_cstr (&lexer->tokstr));
709 /* Weird line processing functions. */
711 /* Returns the entire contents of the current line. */
713 lex_entire_line (struct lexer *lexer)
715 return ds_cstr (&lexer->line_buffer);
718 const struct string *
719 lex_entire_line_ds (struct lexer *lexer)
721 return &lexer->line_buffer;
724 /* As lex_entire_line(), but only returns the part of the current line
725 that hasn't already been tokenized.
726 If END_DOT is non-null, stores nonzero into *END_DOT if the line
727 ends with a terminal dot, or zero if it doesn't. */
729 lex_rest_of_line (struct lexer *lexer, int *end_dot)
732 *end_dot = lexer->dot;
736 /* Causes the rest of the current input line to be ignored for
737 tokenization purposes. */
739 lex_discard_line (struct lexer *lexer)
741 ds_cstr (&lexer->line_buffer); /* Ensures ds_end points to something valid */
742 lexer->prog = ds_end (&lexer->line_buffer);
744 lexer->put_token = 0;
748 /* Discards the rest of the current command.
749 When we're reading commands from a file, we skip tokens until
750 a terminal dot or EOF.
751 When we're reading commands interactively from the user,
752 that's just discarding the current line, because presumably
753 the user doesn't want to finish typing a command that will be
756 lex_discard_rest_of_command (struct lexer *lexer)
758 if (!getl_is_interactive (lexer->ss))
760 while (lexer->token != T_STOP && lexer->token != '.')
764 lex_discard_line (lexer);
767 /* Weird line reading functions. */
769 /* Remove C-style comments in STRING, begun by slash-star and
770 terminated by star-slash or newline. */
772 strip_comments (struct string *string)
780 for (cp = ds_cstr (string); *cp; )
782 /* If we're not in a comment, check for quote marks. */
787 else if (*cp == '\'' || *cp == '"')
791 /* If we're not inside a quotation, check for comment. */
794 if (cp[0] == '/' && cp[1] == '*')
801 else if (in_comment && cp[0] == '*' && cp[1] == '/')
810 /* Check commenting. */
817 /* Prepares LINE, which is subject to the given SYNTAX rules, for
818 tokenization by stripping comments and determining whether it
819 is the beginning or end of a command and storing into
820 *LINE_STARTS_COMMAND and *LINE_ENDS_COMMAND appropriately. */
822 lex_preprocess_line (struct string *line,
823 enum getl_syntax syntax,
824 bool *line_starts_command,
825 bool *line_ends_command)
827 strip_comments (line);
828 ds_rtrim (line, ss_cstr (CC_SPACES));
829 *line_ends_command = (ds_chomp (line, get_endcmd ())
830 || (ds_is_empty (line) && get_nulline ()));
831 *line_starts_command = false;
832 if (syntax == GETL_BATCH)
834 int first = ds_first (line);
835 *line_starts_command = !isspace (first);
836 if (first == '+' || first == '-')
837 *ds_data (line) = ' ';
841 /* Reads a line, without performing any preprocessing.
842 Sets *SYNTAX, if SYNTAX is non-null, to the line's syntax
845 lex_get_line_raw (struct lexer *lexer, enum getl_syntax *syntax)
847 enum getl_syntax dummy;
848 bool ok = getl_read_line (lexer->ss, &lexer->line_buffer,
849 syntax != NULL ? syntax : &dummy);
853 /* Reads a line for use by the tokenizer, and preprocesses it by
854 removing comments, stripping trailing whitespace and the
855 terminal dot, and removing leading indentors. */
857 lex_get_line (struct lexer *lexer)
859 bool line_starts_command;
860 enum getl_syntax syntax;
862 if (!lex_get_line_raw (lexer, &syntax))
868 lex_preprocess_line (&lexer->line_buffer, syntax,
869 &line_starts_command, &lexer->dot);
871 if (line_starts_command)
872 lexer->put_token = '.';
874 lexer->prog = ds_cstr (&lexer->line_buffer);
880 /* Returns the name of a token. */
882 lex_token_name (int token)
884 if (lex_is_keyword (token))
885 return lex_id_name (token);
886 else if (token < 256)
888 static char t[256][2];
898 /* Returns an ASCII representation of the current token as a
899 malloc()'d string. */
901 lex_token_representation (struct lexer *lexer)
905 switch (lexer->token)
910 return ds_xstrdup (&lexer->tokstr);
918 for (sp = ds_cstr (&lexer->tokstr); sp < ds_end (&lexer->tokstr); sp++)
919 if (!isprint ((unsigned char) *sp))
925 token_rep = xmalloc (2 + ds_length (&lexer->tokstr) * 2 + 1 + 1);
933 for (sp = ds_cstr (&lexer->tokstr); *sp; )
937 *dp++ = (unsigned char) *sp++;
940 for (sp = ds_cstr (&lexer->tokstr); sp < ds_end (&lexer->tokstr); sp++)
942 *dp++ = (((unsigned char) *sp) >> 4)["0123456789ABCDEF"];
943 *dp++ = (((unsigned char) *sp) & 15)["0123456789ABCDEF"];
953 token_rep = xmalloc (1);
958 return xstrdup ("**");
961 return xstrdup (lex_token_name (lexer->token));
967 /* Really weird functions. */
969 /* Most of the time, a `-' is a lead-in to a negative number. But
970 sometimes it's actually part of the syntax. If a dash can be part
971 of syntax then this function is called to rip it off of a
974 lex_negative_to_dash (struct lexer *lexer)
976 if (lexer->token == T_NEG_NUM)
978 lexer->token = T_POS_NUM;
979 lexer->tokval = -lexer->tokval;
980 ds_assign_substring (&lexer->tokstr, ds_substr (&lexer->tokstr, 1, SIZE_MAX));
986 /* Skip a COMMENT command. */
988 lex_skip_comment (struct lexer *lexer)
992 if (!lex_get_line (lexer))
994 lexer->put_token = T_STOP;
999 if (lexer->put_token == '.')
1002 ds_cstr (&lexer->line_buffer); /* Ensures ds_end will point to a valid char */
1003 lexer->prog = ds_end (&lexer->line_buffer);
1009 /* Private functions. */
1011 /* When invoked, tokstr contains a string of binary, octal, or
1012 hex digits, according to TYPE. The string is converted to
1013 characters having the specified values. */
1015 convert_numeric_string_to_char_string (struct lexer *lexer,
1016 enum string_type type)
1018 const char *base_name;
1028 base_name = _("binary");
1033 base_name = _("octal");
1038 base_name = _("hex");
1046 byte_cnt = ds_length (&lexer->tokstr) / chars_per_byte;
1047 if (ds_length (&lexer->tokstr) % chars_per_byte)
1048 msg (SE, _("String of %s digits has %d characters, which is not a "
1050 base_name, ds_length (&lexer->tokstr), chars_per_byte);
1052 p = ds_cstr (&lexer->tokstr);
1053 for (i = 0; i < byte_cnt; i++)
1059 for (j = 0; j < chars_per_byte; j++, p++)
1063 if (*p >= '0' && *p <= '9')
1067 static const char alpha[] = "abcdef";
1068 const char *q = strchr (alpha, tolower ((unsigned char) *p));
1077 msg (SE, _("`%c' is not a valid %s digit."), *p, base_name);
1079 value = value * base + v;
1082 ds_cstr (&lexer->tokstr)[i] = (unsigned char) value;
1085 ds_truncate (&lexer->tokstr, byte_cnt);
1088 /* Parses a string from the input buffer into tokstr. The input
1089 buffer pointer lexer->prog must point to the initial single or double
1090 quote. TYPE indicates the type of string to be parsed.
1091 Returns token type. */
1093 parse_string (struct lexer *lexer, enum string_type type)
1095 if (type != CHARACTER_STRING)
1098 /* Accumulate the entire string, joining sections indicated by +
1102 /* Single or double quote. */
1103 int c = *lexer->prog++;
1105 /* Accumulate section. */
1108 /* Check end of line. */
1109 if (*lexer->prog == '\0')
1111 msg (SE, _("Unterminated string constant."));
1115 /* Double quote characters to embed them in strings. */
1116 if (*lexer->prog == c)
1118 if (lexer->prog[1] == c)
1124 ds_put_char (&lexer->tokstr, *lexer->prog++);
1128 /* Skip whitespace after final quote mark. */
1129 if (lexer->prog == NULL)
1133 while (isspace ((unsigned char) *lexer->prog))
1141 if (!lex_get_line (lexer))
1145 /* Skip plus sign. */
1146 if (*lexer->prog != '+')
1150 /* Skip whitespace after plus sign. */
1151 if (lexer->prog == NULL)
1155 while (isspace ((unsigned char) *lexer->prog))
1163 if (!lex_get_line (lexer))
1165 msg (SE, _("Unexpected end of file in string concatenation."));
1170 /* Ensure that a valid string follows. */
1171 if (*lexer->prog != '\'' && *lexer->prog != '"')
1173 msg (SE, _("String expected following `+'."));
1178 /* We come here when we've finished concatenating all the string sections
1179 into one large string. */
1181 if (type != CHARACTER_STRING)
1182 convert_numeric_string_to_char_string (lexer, type);
1184 if (ds_length (&lexer->tokstr) > 255)
1186 msg (SE, _("String exceeds 255 characters in length (%d characters)."),
1187 ds_length (&lexer->tokstr));
1188 ds_truncate (&lexer->tokstr, 255);
1195 /* Reads one token from the lexer and writes a textual representation
1196 on stdout for debugging purposes. */
1198 dump_token (struct lexer *lexer)
1204 curln = getl_source_location (lexer->ss);
1205 curfn = getl_source_name (lexer->ss);
1207 fprintf (stderr, "%s:%d\t", curfn, curln);
1210 switch (lexer->token)
1213 fprintf (stderr, "ID\t%s\n", lexer->tokid);
1218 fprintf (stderr, "NUM\t%f\n", lexer->tokval);
1222 fprintf (stderr, "STRING\t\"%s\"\n", ds_cstr (&lexer->tokstr));
1226 fprintf (stderr, "STOP\n");
1230 fprintf (stderr, "MISC\tEXP\"");
1234 fprintf (stderr, "MISC\tEOF\n");
1238 if (lex_is_keyword (lexer->token))
1239 fprintf (stderr, "KEYWORD\t%s\n", lex_token_name (lexer->token));
1241 fprintf (stderr, "PUNCT\t%c\n", lexer->token);
1245 #endif /* DUMP_TOKENS */
1248 /* Token Accessor Functions */
1251 lex_token (const struct lexer *lexer)
1253 return lexer->token;
1257 lex_tokval (const struct lexer *lexer)
1259 return lexer->tokval;
1263 lex_tokid (const struct lexer *lexer)
1265 return lexer->tokid;
1268 const struct string *
1269 lex_tokstr (const struct lexer *lexer)
1271 return &lexer->tokstr;