X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=fml%2Ffmltoken.c;h=fb34f14e70edb8c26501b6b9e945e79c16cbedee;hb=0a676c9bb4180297bc9deea8c31bec0802b52015;hp=3e7793a50383ea041d58ce02afd60bfe24aa7320;hpb=345de2254e0c2f8c5f40951d0509e8f5ddbc11a9;p=egate.git diff --git a/fml/fmltoken.c b/fml/fmltoken.c index 3e7793a..fb34f14 100644 --- a/fml/fmltoken.c +++ b/fml/fmltoken.c @@ -2,8 +2,23 @@ * FML interpreter. Europagate, 1995 * * $Log: fmltoken.c,v $ - * Revision 1.1 1995/02/06 13:48:09 adam - * Initial revision + * Revision 1.4 1995/02/10 18:15:53 adam + * FML function 'strcmp' implemented. This function can be used to + * test for existence of MARC fields. + * + * Revision 1.3 1995/02/10 15:50:57 adam + * MARC interface implemented. Minor bugs fixed. fmltest can + * be used to format single MARC records. New function '\list' + * implemented. + * + * Revision 1.2 1995/02/07 16:09:24 adam + * The \ character is no longer INCLUDED when terminating a token. + * Major changes in tokenization routines. Bug fixes in expressions + * with lists (fml_sub0). + * + * Revision 1.1.1.1 1995/02/06 13:48:10 adam + * First version of the FML interpreter. It's slow and memory isn't + * freed properly. In particular, the FML nodes aren't released yet. * */ #include @@ -31,6 +46,11 @@ struct fml_node *fml_tokenize (Fml fml) fml_pr_list (p); printf ("\n"); } + if (look_char != fml->eof_mark) + { + fprintf (stderr, "Ill formed parantheses"); + exit (1); + } return p; } @@ -79,24 +99,15 @@ struct fml_node *fml_group (Fml fml) { struct fml_node *sptr = fml_group (fml); if (sptr) - if (sptr->p[1]) - { - ptr2 = fml_node_alloc (fml); - if (!ptr0) - ptr0 = ptr2; - else - ptr1->p[1] = ptr2; - ptr2->p[0] = sptr; - ptr2->is_atom = 0; - } + { + ptr2 = fml_node_alloc (fml); + if (!ptr0) + ptr0 = ptr2; else - { - ptr2 = sptr; - if (!ptr0) - ptr0 = ptr2; - else ptr1->p[1] = ptr2; - } + ptr2->p[0] = sptr; + ptr2->is_atom = 0; + } else { ptr2 = fml_node_alloc (fml); @@ -148,6 +159,38 @@ static void lexer (Fml fml) look_type = '}'; look_char = (*fml->read_func)(); } + else if (look_char == '\'') + { + off = 0; + look_char = (*fml->read_func)(); + while (look_char != fml->eof_mark && look_char != '\'') + { + lex_buf[off++] = look_char; + if (look_char == '\\') + { + look_char = (*fml->read_func)(); + switch (look_char) + { + case 'n': + lex_buf[off-1] = '\n'; + break; + case 't': + lex_buf[off-1] = '\n'; + break; + case '\'': + lex_buf[off-1] = '\''; + break; + default: + lex_buf[off-1] = look_char; + } + } + look_char = (*fml->read_func)(); + } + lex_buf[off] = '\0'; + look_type = 'a'; + if (look_char == '\'') + look_char = (*fml->read_func)(); + } else { off = 0;