1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU 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, see <http://www.gnu.org/licenses/>. */
19 #include <libpspp/message.h>
26 #include <libpspp/alloc.h>
27 #include <libpspp/assertion.h>
28 #include <language/command.h>
29 #include <libpspp/message.h>
30 #include <libpspp/magic.h>
31 #include <data/settings.h>
32 #include <libpspp/getl.h>
33 #include <libpspp/str.h>
34 #include <output/journal.h>
39 #define _(msgid) gettext (msgid)
40 #define N_(msgid) msgid
48 struct string line_buffer;
50 struct source_stream *ss;
52 int token; /* Current token. */
53 double tokval; /* T_POS_NUM, T_NEG_NUM: the token's value. */
55 char tokid [LONG_NAME_LEN + 1]; /* T_ID: the identifier. */
57 struct string tokstr; /* T_ID, T_STRING: token string value.
58 For T_ID, this is not truncated as is
61 char *prog; /* Pointer to next token in line_buffer. */
62 bool dot; /* True only if this line ends with a terminal dot. */
64 int put_token ; /* If nonzero, next token returned by lex_get().
65 Used only in exceptional circumstances. */
67 struct string put_tokstr;
72 static int parse_id (struct lexer *);
74 /* How a string represents its contents. */
77 CHARACTER_STRING, /* Characters. */
78 BINARY_STRING, /* Binary digits. */
79 OCTAL_STRING, /* Octal digits. */
80 HEX_STRING /* Hexadecimal digits. */
83 static int parse_string (struct lexer *, enum string_type);
86 static void dump_token (struct lexer *);
91 /* Initializes the lexer. */
93 lex_create (struct source_stream *ss)
95 struct lexer *lexer = xzalloc (sizeof (*lexer));
97 ds_init_empty (&lexer->tokstr);
98 ds_init_empty (&lexer->put_tokstr);
99 ds_init_empty (&lexer->line_buffer);
105 struct source_stream *
106 lex_get_source_stream (const struct lexer *lex)
113 lex_destroy (struct lexer *lexer)
117 ds_destroy (&lexer->put_tokstr);
118 ds_destroy (&lexer->tokstr);
119 ds_destroy (&lexer->line_buffer);
126 /* Common functions. */
128 /* Copies put_token, lexer->put_tokstr, put_tokval into token, tokstr,
129 tokval, respectively, and sets tokid appropriately. */
131 restore_token (struct lexer *lexer)
133 assert (lexer->put_token != 0);
134 lexer->token = lexer->put_token;
135 ds_assign_string (&lexer->tokstr, &lexer->put_tokstr);
136 str_copy_trunc (lexer->tokid, sizeof lexer->tokid, ds_cstr (&lexer->tokstr));
137 lexer->tokval = lexer->put_tokval;
138 lexer->put_token = 0;
141 /* Copies token, tokstr, lexer->tokval into lexer->put_token, put_tokstr,
142 put_lexer->tokval respectively. */
144 save_token (struct lexer *lexer)
146 lexer->put_token = lexer->token;
147 ds_assign_string (&lexer->put_tokstr, &lexer->tokstr);
148 lexer->put_tokval = lexer->tokval;
151 /* Parses a single token, setting appropriate global variables to
152 indicate the token's attributes. */
154 lex_get (struct lexer *lexer)
159 if (NULL == lexer->prog && ! lex_get_line (lexer) )
161 lexer->token = T_STOP;
165 /* If a token was pushed ahead, return it. */
166 if (lexer->put_token)
168 restore_token (lexer);
177 /* Skip whitespace. */
178 while (isspace ((unsigned char) *lexer->prog))
193 else if (!lex_get_line (lexer))
196 lexer->token = T_STOP;
203 if (lexer->put_token)
205 restore_token (lexer);
214 /* Actually parse the token. */
215 ds_clear (&lexer->tokstr);
217 switch (*lexer->prog)
220 case '0': case '1': case '2': case '3': case '4':
221 case '5': case '6': case '7': case '8': case '9':
225 /* `-' can introduce a negative number, or it can be a
226 token by itself. If it is not followed by a digit or a
227 decimal point, it is definitely not a number.
228 Otherwise, it might be either, but most of the time we
229 want it as a number. When the syntax calls for a `-'
230 token, lex_negative_to_dash() must be used to break
231 negative numbers into two tokens. */
232 if (*lexer->prog == '-')
234 ds_put_char (&lexer->tokstr, *lexer->prog++);
235 while (isspace ((unsigned char) *lexer->prog))
238 if (!isdigit ((unsigned char) *lexer->prog) && *lexer->prog != '.')
243 lexer->token = T_NEG_NUM;
246 lexer->token = T_POS_NUM;
248 /* Parse the number, copying it into tokstr. */
249 while (isdigit ((unsigned char) *lexer->prog))
250 ds_put_char (&lexer->tokstr, *lexer->prog++);
251 if (*lexer->prog == '.')
253 ds_put_char (&lexer->tokstr, *lexer->prog++);
254 while (isdigit ((unsigned char) *lexer->prog))
255 ds_put_char (&lexer->tokstr, *lexer->prog++);
257 if (*lexer->prog == 'e' || *lexer->prog == 'E')
259 ds_put_char (&lexer->tokstr, *lexer->prog++);
260 if (*lexer->prog == '+' || *lexer->prog == '-')
261 ds_put_char (&lexer->tokstr, *lexer->prog++);
262 while (isdigit ((unsigned char) *lexer->prog))
263 ds_put_char (&lexer->tokstr, *lexer->prog++);
266 /* Parse as floating point. */
267 lexer->tokval = strtod (ds_cstr (&lexer->tokstr), &tail);
270 msg (SE, _("%s does not form a valid number."),
271 ds_cstr (&lexer->tokstr));
274 ds_clear (&lexer->tokstr);
275 ds_put_char (&lexer->tokstr, '0');
282 lexer->token = parse_string (lexer, CHARACTER_STRING);
285 case '(': case ')': case ',': case '=': case '+': case '/':
286 lexer->token = *lexer->prog++;
290 if (*++lexer->prog == '*')
293 lexer->token = T_EXP;
300 if (*++lexer->prog == '=')
305 else if (*lexer->prog == '>')
315 if (*++lexer->prog == '=')
325 if (*++lexer->prog == '=')
331 lexer->token = T_NOT;
336 lexer->token = T_AND;
345 if (lexer->prog[1] == '\'' || lexer->prog[1] == '"')
346 lexer->token = parse_string (lexer, BINARY_STRING);
348 lexer->token = parse_id (lexer);
352 if (lexer->prog[1] == '\'' || lexer->prog[1] == '"')
353 lexer->token = parse_string (lexer, OCTAL_STRING);
355 lexer->token = parse_id (lexer);
359 if (lexer->prog[1] == '\'' || lexer->prog[1] == '"')
360 lexer->token = parse_string (lexer, HEX_STRING);
362 lexer->token = parse_id (lexer);
366 if (lex_is_id1 (*lexer->prog))
368 lexer->token = parse_id (lexer);
373 if (isgraph ((unsigned char) *lexer->prog))
374 msg (SE, _("Bad character in input: `%c'."), *lexer->prog++);
376 msg (SE, _("Bad character in input: `\\%o'."), *lexer->prog++);
388 /* Parses an identifier at the current position into tokid and
390 Returns the correct token type. */
392 parse_id (struct lexer *lexer)
394 struct substring rest_of_line
395 = ss_substr (ds_ss (&lexer->line_buffer),
396 ds_pointer_to_position (&lexer->line_buffer, lexer->prog),
398 struct substring id = ss_head (rest_of_line,
399 lex_id_get_length (rest_of_line));
400 lexer->prog += ss_length (id);
402 ds_assign_substring (&lexer->tokstr, id);
403 str_copy_trunc (lexer->tokid, sizeof lexer->tokid, ds_cstr (&lexer->tokstr));
404 return lex_id_to_token (id);
407 /* Reports an error to the effect that subcommand SBC may only be
410 lex_sbc_only_once (const char *sbc)
412 msg (SE, _("Subcommand %s may only be specified once."), sbc);
415 /* Reports an error to the effect that subcommand SBC is
418 lex_sbc_missing (struct lexer *lexer, const char *sbc)
420 lex_error (lexer, _("missing required subcommand %s"), sbc);
423 /* Prints a syntax error message containing the current token and
424 given message MESSAGE (if non-null). */
426 lex_error (struct lexer *lexer, const char *message, ...)
431 token_rep = lex_token_representation (lexer);
432 if (lexer->token == T_STOP)
433 strcpy (where, "end of file");
434 else if (lexer->token == '.')
435 strcpy (where, "end of command");
437 snprintf (where, sizeof where, "`%s'", token_rep);
445 va_start (args, message);
446 vsnprintf (buf, 1024, message, args);
449 msg (SE, _("Syntax error %s at %s."), buf, where);
452 msg (SE, _("Syntax error at %s."), where);
455 /* Checks that we're at end of command.
456 If so, returns a successful command completion code.
457 If not, flags a syntax error and returns an error command
460 lex_end_of_command (struct lexer *lexer)
462 if (lexer->token != '.')
464 lex_error (lexer, _("expecting end of command"));
471 /* Token testing functions. */
473 /* Returns true if the current token is a number. */
475 lex_is_number (struct lexer *lexer)
477 return lexer->token == T_POS_NUM || lexer->token == T_NEG_NUM;
481 /* Returns true if the current token is a string. */
483 lex_is_string (struct lexer *lexer)
485 return lexer->token == T_STRING;
489 /* Returns the value of the current token, which must be a
490 floating point number. */
492 lex_number (struct lexer *lexer)
494 assert (lex_is_number (lexer));
495 return lexer->tokval;
498 /* Returns true iff the current token is an integer. */
500 lex_is_integer (struct lexer *lexer)
502 return (lex_is_number (lexer)
503 && lexer->tokval != NOT_LONG
504 && lexer->tokval >= LONG_MIN
505 && lexer->tokval <= LONG_MAX
506 && floor (lexer->tokval) == lexer->tokval);
509 /* Returns the value of the current token, which must be an
512 lex_integer (struct lexer *lexer)
514 assert (lex_is_integer (lexer));
515 return lexer->tokval;
518 /* Token matching functions. */
520 /* If TOK is the current token, skips it and returns true
521 Otherwise, returns false. */
523 lex_match (struct lexer *lexer, int t)
525 if (lexer->token == t)
534 /* If the current token is the identifier S, skips it and returns
535 true. The identifier may be abbreviated to its first three
537 Otherwise, returns false. */
539 lex_match_id (struct lexer *lexer, const char *s)
541 if (lexer->token == T_ID
542 && lex_id_match (ss_cstr (s), ss_cstr (lexer->tokid)))
551 /* If the current token is integer N, skips it and returns true.
552 Otherwise, returns false. */
554 lex_match_int (struct lexer *lexer, int x)
556 if (lex_is_integer (lexer) && lex_integer (lexer) == x)
565 /* Forced matches. */
567 /* If this token is identifier S, fetches the next token and returns
569 Otherwise, reports an error and returns zero. */
571 lex_force_match_id (struct lexer *lexer, const char *s)
573 if (lex_match_id (lexer, s))
577 lex_error (lexer, _("expecting `%s'"), s);
582 /* If the current token is T, skips the token. Otherwise, reports an
583 error and returns from the current function with return value false. */
585 lex_force_match (struct lexer *lexer, int t)
587 if (lexer->token == t)
594 lex_error (lexer, _("expecting `%s'"), lex_token_name (t));
599 /* If this token is a string, does nothing and returns true.
600 Otherwise, reports an error and returns false. */
602 lex_force_string (struct lexer *lexer)
604 if (lexer->token == T_STRING)
608 lex_error (lexer, _("expecting string"));
613 /* If this token is an integer, does nothing and returns true.
614 Otherwise, reports an error and returns false. */
616 lex_force_int (struct lexer *lexer)
618 if (lex_is_integer (lexer))
622 lex_error (lexer, _("expecting integer"));
627 /* If this token is a number, does nothing and returns true.
628 Otherwise, reports an error and returns false. */
630 lex_force_num (struct lexer *lexer)
632 if (lex_is_number (lexer))
635 lex_error (lexer, _("expecting number"));
639 /* If this token is an identifier, does nothing and returns true.
640 Otherwise, reports an error and returns false. */
642 lex_force_id (struct lexer *lexer)
644 if (lexer->token == T_ID)
647 lex_error (lexer, _("expecting identifier"));
651 /* Weird token functions. */
653 /* Returns the first character of the next token, except that if the
654 next token is not an identifier, the character returned will not be
655 a character that can begin an identifier. Specifically, the
656 hexstring lead-in X' causes lookahead() to return '. Note that an
657 alphanumeric return value doesn't guarantee an ID token, it could
658 also be a reserved-word token. */
660 lex_look_ahead (struct lexer *lexer)
662 if (lexer->put_token)
663 return lexer->put_token;
667 if (NULL == lexer->prog && ! lex_get_line (lexer) )
672 while (isspace ((unsigned char) *lexer->prog))
679 else if (!lex_get_line (lexer))
682 if (lexer->put_token)
683 return lexer->put_token;
686 if ((toupper ((unsigned char) *lexer->prog) == 'X'
687 || toupper ((unsigned char) *lexer->prog) == 'B'
688 || toupper ((unsigned char) *lexer->prog) == 'O')
689 && (lexer->prog[1] == '\'' || lexer->prog[1] == '"'))
696 /* Makes the current token become the next token to be read; the
697 current token is set to T. */
699 lex_put_back (struct lexer *lexer, int t)
705 /* Makes the current token become the next token to be read; the
706 current token is set to the identifier ID. */
708 lex_put_back_id (struct lexer *lexer, const char *id)
710 assert (lex_id_to_token (ss_cstr (id)) == T_ID);
713 ds_assign_cstr (&lexer->tokstr, id);
714 str_copy_trunc (lexer->tokid, sizeof lexer->tokid, ds_cstr (&lexer->tokstr));
717 /* Weird line processing functions. */
719 /* Returns the entire contents of the current line. */
721 lex_entire_line (const struct lexer *lexer)
723 return ds_cstr (&lexer->line_buffer);
726 const struct string *
727 lex_entire_line_ds (const struct lexer *lexer)
729 return &lexer->line_buffer;
732 /* As lex_entire_line(), but only returns the part of the current line
733 that hasn't already been tokenized. */
735 lex_rest_of_line (const struct lexer *lexer)
740 /* Returns true if the current line ends in a terminal dot,
743 lex_end_dot (const struct lexer *lexer)
748 /* Causes the rest of the current input line to be ignored for
749 tokenization purposes. */
751 lex_discard_line (struct lexer *lexer)
753 ds_cstr (&lexer->line_buffer); /* Ensures ds_end points to something valid */
754 lexer->prog = ds_end (&lexer->line_buffer);
756 lexer->put_token = 0;
760 /* Discards the rest of the current command.
761 When we're reading commands from a file, we skip tokens until
762 a terminal dot or EOF.
763 When we're reading commands interactively from the user,
764 that's just discarding the current line, because presumably
765 the user doesn't want to finish typing a command that will be
768 lex_discard_rest_of_command (struct lexer *lexer)
770 if (!getl_is_interactive (lexer->ss))
772 while (lexer->token != T_STOP && lexer->token != '.')
776 lex_discard_line (lexer);
779 /* Weird line reading functions. */
781 /* Remove C-style comments in STRING, begun by slash-star and
782 terminated by star-slash or newline. */
784 strip_comments (struct string *string)
792 for (cp = ds_cstr (string); *cp; )
794 /* If we're not in a comment, check for quote marks. */
799 else if (*cp == '\'' || *cp == '"')
803 /* If we're not inside a quotation, check for comment. */
806 if (cp[0] == '/' && cp[1] == '*')
813 else if (in_comment && cp[0] == '*' && cp[1] == '/')
822 /* Check commenting. */
829 /* Prepares LINE, which is subject to the given SYNTAX rules, for
830 tokenization by stripping comments and determining whether it
831 is the beginning or end of a command and storing into
832 *LINE_STARTS_COMMAND and *LINE_ENDS_COMMAND appropriately. */
834 lex_preprocess_line (struct string *line,
835 enum getl_syntax syntax,
836 bool *line_starts_command,
837 bool *line_ends_command)
839 strip_comments (line);
840 ds_rtrim (line, ss_cstr (CC_SPACES));
841 *line_ends_command = (ds_chomp (line, get_endcmd ())
842 || (ds_is_empty (line) && get_nulline ()));
843 *line_starts_command = false;
844 if (syntax == GETL_BATCH)
846 int first = ds_first (line);
847 *line_starts_command = !isspace (first);
848 if (first == '+' || first == '-')
849 *ds_data (line) = ' ';
853 /* Reads a line, without performing any preprocessing.
854 Sets *SYNTAX, if SYNTAX is non-null, to the line's syntax
857 lex_get_line_raw (struct lexer *lexer, enum getl_syntax *syntax)
859 enum getl_syntax dummy;
864 ok = getl_read_line (lexer->ss, &lexer->line_buffer, syntax);
865 journal_write (*syntax == GETL_BATCH, ds_cstr (&lexer->line_buffer));
870 /* Reads a line for use by the tokenizer, and preprocesses it by
871 removing comments, stripping trailing whitespace and the
872 terminal dot, and removing leading indentors. */
874 lex_get_line (struct lexer *lexer)
876 bool line_starts_command;
877 enum getl_syntax syntax = GETL_BATCH;
879 if (!lex_get_line_raw (lexer, &syntax))
885 lex_preprocess_line (&lexer->line_buffer, syntax,
886 &line_starts_command, &lexer->dot);
888 if (line_starts_command)
889 lexer->put_token = '.';
891 lexer->prog = ds_cstr (&lexer->line_buffer);
897 /* Returns the name of a token. */
899 lex_token_name (int token)
901 if (lex_is_keyword (token))
902 return lex_id_name (token);
903 else if (token < 256)
905 static char t[256][2];
915 /* Returns an ASCII representation of the current token as a
916 malloc()'d string. */
918 lex_token_representation (struct lexer *lexer)
922 switch (lexer->token)
927 return ds_xstrdup (&lexer->tokstr);
935 for (sp = ds_cstr (&lexer->tokstr); sp < ds_end (&lexer->tokstr); sp++)
936 if (!isprint ((unsigned char) *sp))
942 token_rep = xmalloc (2 + ds_length (&lexer->tokstr) * 2 + 1 + 1);
950 for (sp = ds_cstr (&lexer->tokstr); *sp; )
954 *dp++ = (unsigned char) *sp++;
957 for (sp = ds_cstr (&lexer->tokstr); sp < ds_end (&lexer->tokstr); sp++)
959 *dp++ = (((unsigned char) *sp) >> 4)["0123456789ABCDEF"];
960 *dp++ = (((unsigned char) *sp) & 15)["0123456789ABCDEF"];
970 token_rep = xmalloc (1);
975 return xstrdup ("**");
978 return xstrdup (lex_token_name (lexer->token));
984 /* Really weird functions. */
986 /* Most of the time, a `-' is a lead-in to a negative number. But
987 sometimes it's actually part of the syntax. If a dash can be part
988 of syntax then this function is called to rip it off of a
991 lex_negative_to_dash (struct lexer *lexer)
993 if (lexer->token == T_NEG_NUM)
995 lexer->token = T_POS_NUM;
996 lexer->tokval = -lexer->tokval;
997 ds_assign_substring (&lexer->tokstr, ds_substr (&lexer->tokstr, 1, SIZE_MAX));
1003 /* Skip a COMMENT command. */
1005 lex_skip_comment (struct lexer *lexer)
1009 if (!lex_get_line (lexer))
1011 lexer->put_token = T_STOP;
1016 if (lexer->put_token == '.')
1019 ds_cstr (&lexer->line_buffer); /* Ensures ds_end will point to a valid char */
1020 lexer->prog = ds_end (&lexer->line_buffer);
1026 /* Private functions. */
1028 /* When invoked, tokstr contains a string of binary, octal, or
1029 hex digits, according to TYPE. The string is converted to
1030 characters having the specified values. */
1032 convert_numeric_string_to_char_string (struct lexer *lexer,
1033 enum string_type type)
1035 const char *base_name;
1045 base_name = _("binary");
1050 base_name = _("octal");
1055 base_name = _("hex");
1063 byte_cnt = ds_length (&lexer->tokstr) / chars_per_byte;
1064 if (ds_length (&lexer->tokstr) % chars_per_byte)
1065 msg (SE, _("String of %s digits has %d characters, which is not a "
1067 base_name, (int) ds_length (&lexer->tokstr), chars_per_byte);
1069 p = ds_cstr (&lexer->tokstr);
1070 for (i = 0; i < byte_cnt; i++)
1076 for (j = 0; j < chars_per_byte; j++, p++)
1080 if (*p >= '0' && *p <= '9')
1084 static const char alpha[] = "abcdef";
1085 const char *q = strchr (alpha, tolower ((unsigned char) *p));
1094 msg (SE, _("`%c' is not a valid %s digit."), *p, base_name);
1096 value = value * base + v;
1099 ds_cstr (&lexer->tokstr)[i] = (unsigned char) value;
1102 ds_truncate (&lexer->tokstr, byte_cnt);
1105 /* Parses a string from the input buffer into tokstr. The input
1106 buffer pointer lexer->prog must point to the initial single or double
1107 quote. TYPE indicates the type of string to be parsed.
1108 Returns token type. */
1110 parse_string (struct lexer *lexer, enum string_type type)
1112 if (type != CHARACTER_STRING)
1115 /* Accumulate the entire string, joining sections indicated by +
1119 /* Single or double quote. */
1120 int c = *lexer->prog++;
1122 /* Accumulate section. */
1125 /* Check end of line. */
1126 if (*lexer->prog == '\0')
1128 msg (SE, _("Unterminated string constant."));
1132 /* Double quote characters to embed them in strings. */
1133 if (*lexer->prog == c)
1135 if (lexer->prog[1] == c)
1141 ds_put_char (&lexer->tokstr, *lexer->prog++);
1145 /* Skip whitespace after final quote mark. */
1146 if (lexer->prog == NULL)
1150 while (isspace ((unsigned char) *lexer->prog))
1158 if (!lex_get_line (lexer))
1162 /* Skip plus sign. */
1163 if (*lexer->prog != '+')
1167 /* Skip whitespace after plus sign. */
1168 if (lexer->prog == NULL)
1172 while (isspace ((unsigned char) *lexer->prog))
1180 if (!lex_get_line (lexer))
1182 msg (SE, _("Unexpected end of file in string concatenation."));
1187 /* Ensure that a valid string follows. */
1188 if (*lexer->prog != '\'' && *lexer->prog != '"')
1190 msg (SE, _("String expected following `+'."));
1195 /* We come here when we've finished concatenating all the string sections
1196 into one large string. */
1198 if (type != CHARACTER_STRING)
1199 convert_numeric_string_to_char_string (lexer, type);
1201 if (ds_length (&lexer->tokstr) > 255)
1203 msg (SE, _("String exceeds 255 characters in length (%d characters)."),
1204 (int) ds_length (&lexer->tokstr));
1205 ds_truncate (&lexer->tokstr, 255);
1212 /* Reads one token from the lexer and writes a textual representation
1213 on stdout for debugging purposes. */
1215 dump_token (struct lexer *lexer)
1221 curln = getl_source_location (lexer->ss);
1222 curfn = getl_source_name (lexer->ss);
1224 fprintf (stderr, "%s:%d\t", curfn, curln);
1227 switch (lexer->token)
1230 fprintf (stderr, "ID\t%s\n", lexer->tokid);
1235 fprintf (stderr, "NUM\t%f\n", lexer->tokval);
1239 fprintf (stderr, "STRING\t\"%s\"\n", ds_cstr (&lexer->tokstr));
1243 fprintf (stderr, "STOP\n");
1247 fprintf (stderr, "MISC\tEXP\"");
1251 fprintf (stderr, "MISC\tEOF\n");
1255 if (lex_is_keyword (lexer->token))
1256 fprintf (stderr, "KEYWORD\t%s\n", lex_token_name (lexer->token));
1258 fprintf (stderr, "PUNCT\t%c\n", lexer->token);
1262 #endif /* DUMP_TOKENS */
1265 /* Token Accessor Functions */
1268 lex_token (const struct lexer *lexer)
1270 return lexer->token;
1274 lex_tokval (const struct lexer *lexer)
1276 return lexer->tokval;
1280 lex_tokid (const struct lexer *lexer)
1282 return lexer->tokid;
1285 const struct string *
1286 lex_tokstr (const struct lexer *lexer)
1288 return &lexer->tokstr;