source: branches/z3950-branch/gsdl/src/recpt/parse.fl@ 1168

Last change on this file since 1168 was 1168, checked in by johnmcp, 24 years ago

added proper config file parsing for z39.50 servers, and minor changes
to pageaction (minor bug when display collections from >1 proto) and
cgiwrapper (announces which collections are z39.50 servers).

  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1/* This is the lexical analyser - it returns tokens to the parsers.
2 This is used by both parsers - one for the build-time config files
3 and one for the run-time config files. Note the included file "parse.h"
4 is a symlink to the relevant header file. */
5
6%{
7#include <string.h>
8#include <stdlib.h>
9#include <stdio.h>
10
11/*#define YYSTYPE char * - YYSTYPE is defined in zparse.tab.h */
12#include "zparse.tab.h"
13
14/* forward declarations for std functions not picked up. */
15/*int fileno(FILE *);*/
16/*char *strdup(char *);*/
17
18int lineno=1;
19%}
20
21%option noyywrap
22
23COMMENT \#.*(\n|\r)
24
25%x STRINGCOND
26%%
27 char *string;
28 int string_size;
29
30{COMMENT} lineno++;yylval.string=yytext;
31, return (',');
32: return (':');
33\_ return ('_');
34\[GSDL[0-9]+\.[0-9]+\] yylval.string=yytext;return(GSDLVERSION);
35\[General\] return (GENERAL_SECTION);
36\[Search\ [fF]ields\] return (SEARCH_SECTION);
37\[Browse\ [fF]ields\] return (BROWSE_SECTION);
38\[Macros\] return (MACROS_SECTION);
39maintainer return (MAINTAINER);
40Languages return(LANGUAGES);
41About return(ABOUT);
42en return(EN);
43fr return(FR);
44mi return(MI);
45zh return(ZH);
46de return(DE);
47Browse return(BROWSE);
48Date[lL]ist return(DATELIST);
49Document[aA]rrows[bB]ottom return(DOCUMENTARROWSBOTTOM);
50Document[bB]uttons return(DOCUMENTBUTTONS);
51Document[hH]eader return(DOCUMENTHEADER);
52Document[iI]mages return(DOCUMENTIMAGES);
53Document[tT]ext return(DOCUMENTTEXT);
54Icon[lL]ink return(ICONLINK);
55List return(LIST);
56Format return(FORMAT);
57Name return(NAME);
58Search[tT]ext return(SEARCHTEXT);
59Section[lL]ist return(SECTIONLIST);
60Sorted[lL]ist return(SORTEDLIST);
61Sorted[sS]ection[lL]ist return(SORTEDSECTIONLIST);
62Text[lL]ink return(TEXTLINK);
63Type return(TYPE);
64public return (PUBLIC);
65true return (TRUE);
66false return (FALSE);
67^document return (DOCUMENT);
68^section return (SECTION);
69\"[^\" ]*\" { /* for single word strings */
70 if ((string=strdup(yytext+1))==NULL)
71 {
72 fprintf(stderr,"malloc failed\n");
73 exit(1);
74 }
75 string[strlen(string)-1]='\0'; /* chomp " */
76 /* yylval=yytext; */
77 yylval.string=string;
78 return(STRING);
79 }
80\"[^\"]* {
81 BEGIN(STRINGCOND);
82 /* the +1 is to skip the leading " */
83 if ((string=strdup(yytext+1))==NULL)
84 {
85 fprintf(stderr,"malloc failed\n");
86 exit(1);
87 }
88 else string_size=strlen(yytext)-1;
89 }
90[iI]con return (ICON);
91[sS]mall[iI]con return (SMALLICON);
92<STRINGCOND>{
93 ([^\"\\])* {
94 if (strlen(string)+strlen(yytext)>string_size)
95 { /* what if strlen(yytext) > 40 !!!!!! */
96 if ((string=realloc(string,string_size+40))==NULL)
97 {
98 fprintf(stderr,"realloc failed\n");
99 exit(1);
100 }
101 else string_size+=40;
102 }
103 strcat(string,yytext);
104 }
105 "\\"\" |
106 \"\" { /* replace with a single " */
107 /* yes, this is dodgy for now... */
108 strcat(string,"\"");
109 }
110 \" {
111 BEGIN(INITIAL);
112 yylval.string=string;
113 return(STRING);
114 /* note that the string may have long bits of
115 whitespace in it that could be removed. */
116 }
117}
118[[:alnum:]@\.]+ yylval.string=strdup(yytext);return (DATA);
119(" "|\t) ;
120(\n|\r) lineno++;
121%%
122
123
124
125
126
Note: See TracBrowser for help on using the repository browser.