Abstract the documents within a dictionary a little better. Thanks to
[pspp-builds.git] / src / language / lexer / lexer.c
index ebb8a9ed1ec1bbcad5f22141466718c2cd708113..149e35c715b99b826a09ffd947e9830d9f1ed170 100644 (file)
@@ -478,6 +478,15 @@ lex_is_number (struct lexer *lexer)
   return lexer->token == T_POS_NUM || lexer->token == T_NEG_NUM;
 }
 
+
+/* Returns true if the current token is a string. */
+bool
+lex_is_string (struct lexer *lexer)
+{
+  return lexer->token == T_STRING;
+}
+
+
 /* Returns the value of the current token, which must be a
    floating point number. */
 double
@@ -710,29 +719,33 @@ lex_put_back_id (struct lexer *lexer, const char *id)
 
 /* Returns the entire contents of the current line. */
 const char *
-lex_entire_line (struct lexer *lexer)
+lex_entire_line (const struct lexer *lexer)
 {
   return ds_cstr (&lexer->line_buffer);
 }
 
 const struct string *
-lex_entire_line_ds (struct lexer *lexer)
+lex_entire_line_ds (const struct lexer *lexer)
 {
   return &lexer->line_buffer;
 }
 
 /* As lex_entire_line(), but only returns the part of the current line
-   that hasn't already been tokenized.
-   If END_DOT is non-null, stores nonzero into *END_DOT if the line
-   ends with a terminal dot, or zero if it doesn't. */
+   that hasn't already been tokenized. */
 const char *
-lex_rest_of_line (struct lexer *lexer, int *end_dot)
+lex_rest_of_line (const struct lexer *lexer)
 {
-  if (end_dot)
-    *end_dot = lexer->dot;
   return lexer->prog;
 }
 
+/* Returns true if the current line ends in a terminal dot,
+   false otherwise. */
+bool
+lex_end_dot (const struct lexer *lexer) 
+{
+  return lexer->dot;
+}
+
 /* Causes the rest of the current input line to be ignored for
    tokenization purposes. */
 void
@@ -1047,7 +1060,7 @@ convert_numeric_string_to_char_string (struct lexer *lexer,
   if (ds_length (&lexer->tokstr) % chars_per_byte)
     msg (SE, _("String of %s digits has %d characters, which is not a "
               "multiple of %d."),
-        base_name, ds_length (&lexer->tokstr), chars_per_byte);
+        base_name, (int) ds_length (&lexer->tokstr), chars_per_byte);
 
   p = ds_cstr (&lexer->tokstr);
   for (i = 0; i < byte_cnt; i++)
@@ -1184,7 +1197,7 @@ finish:
   if (ds_length (&lexer->tokstr) > 255)
     {
       msg (SE, _("String exceeds 255 characters in length (%d characters)."),
-          ds_length (&lexer->tokstr));
+          (int) ds_length (&lexer->tokstr));
       ds_truncate (&lexer->tokstr, 255);
     }