X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gedcom_hilo.lex;h=5c674a7a17287cbabb4537f9450797a8293fabe3;hb=8093e53a57e174b019f07760f5bf815271ceee9b;hp=2a05b311660b5846f83e8110239c7f0020a1a380;hpb=b4557a98f5842835e9e65370fd062b6d65af0b14;p=gedcom-parse.git diff --git a/gedcom_hilo.lex b/gedcom_hilo.lex index 2a05b31..5c674a7 100644 --- a/gedcom_hilo.lex +++ b/gedcom_hilo.lex @@ -14,12 +14,10 @@ /* i.e. this is utf-16-be */ %{ -#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_hilo_lex(); +} int main() { - int tok, res; - init_encodings(); - set_encoding_width(TWO_BYTE_HILO); - res = open_conv_to_internal("UNICODE"); - if (!res) { - gedcom_error("Unable to open conversion context: %s", - strerror(errno)); - return 1; - } - tok = gedcom_hilo_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_hilo_lex(); - } - printf("\n"); - close_conv_to_internal(); - return 0; + return test_loop(TWO_BYTE_HILO, "UNICODE"); } #endif