/* $Name$ */
%{
-#include "gedcom.tab.h"
-#include "gedcom.h"
-#include "multilex.h"
-#include "encoding.h"
+#undef IN_LEX /* include only a specific part of the following file */
+#include "gedcom_lex_common.c"
-#define YY_NO_UNPUT
+static size_t encoding_width = 1;
%}
%s NORMAL
escape @#{any_char}+@
pointer @{alphanum}{non_at}+@
-%{
-static int current_level=-1;
-static int level_diff=MAXGEDCLEVEL;
-
-#ifdef LEXER_TEST
-YYSTYPE gedcom_lval;
-int line_no = 1;
-#endif
-
-%}
-
%%
%{
+#define IN_LEX /* include only a specific part of the following file */
#include "gedcom_lex_common.c"
ACTION_BEFORE_REGEXPS
%}
-<INITIAL>{gen_delim}* /* ignore leading whitespace (also tabs) */
+<INITIAL>{gen_delim}* ACTION_INITIAL_WHITESPACE
<INITIAL>0{digit}+ ACTION_0_DIGITS
}
#ifdef LEXER_TEST
+int gedcom_lex()
+{
+ return gedcom_1byte_lex();
+}
+
int main()
{
- int tok, res;
- init_encodings();
- set_encoding_width(ONE_BYTE);
- res = open_conv_to_internal("ASCII");
- if (!res) {
- gedcom_error("Unable to open conversion context: %s",
- strerror(errno));
- return 1;
- }
- tok = gedcom_1byte_lex();
- while (tok) {
- switch(tok) {
- case BADTOKEN: printf("BADTOKEN "); break;
- case OPEN: printf("OPEN(%d) ", gedcom_lval.level); break;
- case CLOSE: printf("CLOSE "); break;
- case ESCAPE: printf("ESCAPE(%s) ", gedcom_lval.string); break;
- case DELIM: printf("DELIM "); break;
- case ANYCHAR: printf("%s ", gedcom_lval.string); break;
- case POINTER: printf("POINTER(%s) ", gedcom_lval.pointer); break;
- case USERTAG: printf("USERTAG(%s) ", gedcom_lval.tag); break;
- default: printf("TAG(%s) ", gedcom_lval.tag); break;
- }
- tok = gedcom_1byte_lex();
- }
- printf("\n");
- close_conv_to_internal();
- return 0;
+ return test_loop(ONE_BYTE, "ASCII");
}
#endif