-bool lex_force_match (int);
-bool lex_force_match_id (const char *);
-bool lex_force_int (void);
-bool lex_force_num (void);
-bool lex_force_id (void);
-bool lex_force_string (void);
-
-/* Weird token functions. */
-int lex_look_ahead (void);
-void lex_put_back (int);
-void lex_put_back_id (const char *tokid);
-
-/* Weird line processing functions. */
-const char *lex_entire_line (void);
-const struct string *lex_entire_line_ds (void);
-const char *lex_rest_of_line (int *end_dot);
-void lex_discard_line (void);
-void lex_discard_rest_of_command (void);
-
-/* Weird line reading functions. */
-bool lex_get_line (void);
-bool lex_get_line_raw (void);
-
-/* Token names. */
-const char *lex_token_name (int);
-char *lex_token_representation (void);
-
-/* Really weird functions. */
-void lex_negative_to_dash (void);
-void lex_reset_eof (void);
-void lex_skip_comment (void);
-
-#endif /* !lexer_h */
+bool lex_force_match (struct lexer *, enum token_type);
+bool lex_force_match_id (struct lexer *, const char *);
+bool lex_force_int (struct lexer *);
+bool lex_force_num (struct lexer *);
+bool lex_force_id (struct lexer *);
+bool lex_force_string (struct lexer *);
+bool lex_force_string_or_id (struct lexer *);
+
+/* Token accessors. */
+enum token_type lex_token (const struct lexer *);
+double lex_tokval (const struct lexer *);
+const char *lex_tokcstr (const struct lexer *);
+struct substring lex_tokss (const struct lexer *);
+
+/* Looking ahead. */
+const struct token *lex_next (const struct lexer *, int n);
+enum token_type lex_next_token (const struct lexer *, int n);
+const char *lex_next_tokcstr (const struct lexer *, int n);
+double lex_next_tokval (const struct lexer *, int n);
+struct substring lex_next_tokss (const struct lexer *, int n);
+
+/* Current position. */
+int lex_get_first_line_number (const struct lexer *, int n);
+int lex_get_last_line_number (const struct lexer *, int n);
+int lex_get_first_column (const struct lexer *, int n);
+int lex_get_last_column (const struct lexer *, int n);
+const char *lex_get_file_name (const struct lexer *);
+
+/* Issuing errors. */
+void lex_error (struct lexer *, const char *, ...) PRINTF_FORMAT (2, 3);
+void lex_next_error (struct lexer *, int n0, int n1, const char *, ...)
+ PRINTF_FORMAT (4, 5);
+int lex_end_of_command (struct lexer *);
+
+void lex_error_expecting (struct lexer *, const char *, ...) SENTINEL(0);
+
+void lex_sbc_only_once (const char *);
+void lex_sbc_missing (const char *);
+
+void lex_spec_only_once (struct lexer *, const char *subcommand,
+ const char *specification);
+void lex_spec_missing (struct lexer *, const char *subcommand,
+ const char *specification);
+
+void lex_error_valist (struct lexer *, const char *, va_list)
+ PRINTF_FORMAT (2, 0);
+void lex_next_error_valist (struct lexer *lexer, int n0, int n1,
+ const char *format, va_list)
+ PRINTF_FORMAT (4, 0);
+
+/* Error handling. */
+enum lex_syntax_mode lex_get_syntax_mode (const struct lexer *);
+enum lex_error_mode lex_get_error_mode (const struct lexer *);
+void lex_discard_rest_of_command (struct lexer *);
+void lex_interactive_reset (struct lexer *);
+void lex_discard_noninteractive (struct lexer *);
+
+#endif /* lexer.h */