X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gedcom_lohi.lex;h=badd835d4015f7a74c80e12a6c4b0e67a8557916;hb=471aa410dba0a5604cc40f4d23fc34efb098c778;hp=e91d4f0693d1a40738ad6c1b2cb81f9f38c4548a;hpb=b4557a98f5842835e9e65370fd062b6d65af0b14;p=gedcom-parse.git diff --git a/gedcom_lohi.lex b/gedcom_lohi.lex index e91d4f0..badd835 100644 --- a/gedcom_lohi.lex +++ b/gedcom_lohi.lex @@ -14,12 +14,10 @@ /* i.e. this is utf-16-le */ %{ -#include "gedcom.tab.h" -#include "gedcom.h" -#include "multilex.h" -#include "encoding.h" - -#define YY_NO_UNPUT +#undef IN_LEX /* include only a specific part of the following file */ +#include "gedcom_lex_common.c" + +static size_t encoding_width = 2; %} %s NORMAL @@ -43,26 +41,17 @@ gen_delim {delim}|{tab} escape @\x00#\x00{any_char}+@\x00 pointer @\x00{alphanum}{non_at}+@\x00 -%{ -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 %} -{gen_delim}* /* ignore leading whitespace (also tabs) */ +{gen_delim}* ACTION_INITIAL_WHITESPACE \x00[0]{digit}+ ACTION_0_DIGITS @@ -222,35 +211,13 @@ int yywrap() } #ifdef LEXER_TEST +int gedcom_lex() +{ + return gedcom_lohi_lex(); +} int main() { - int tok, res; - init_encodings(); - set_encoding_width(TWO_BYTE_LOHI); - res = open_conv_to_internal("UNICODE"); - if (!res) { - gedcom_error("Unable to open conversion context: %s", - strerror(errno)); - return 1; - } - tok = gedcom_lohi_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_lohi_lex(); - } - printf("\n"); - close_conv_to_internal(); - return 0; + return test_loop(TWO_BYTE_LOHI, "UNICODE"); } #endif