source: main/tags/2.80/gsdl/src/recpt/zparse.fl@ 24528

Last change on this file since 24528 was 10705, checked in by jrm21, 19 years ago

tidied up interaction between flex/bison and greenstone's z3950 client
classes. renamed parse.y to zparse.y to make it more obvious it's related
to that stuff.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 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_len;
29
30{COMMENT} lineno++;/*yylval.string=yytext;*/yyleng=0;
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);
42Browse return(BROWSE);
43Date[lL]ist return(DATELIST);
44Document[aA]rrows[bB]ottom return(DOCUMENTARROWSBOTTOM);
45Document[bB]uttons return(DOCUMENTBUTTONS);
46Document[hH]eader return(DOCUMENTHEADER);
47Document[iI]mages return(DOCUMENTIMAGES);
48Document[tT]ext return(DOCUMENTTEXT);
49Icon[lL]ink return(ICONLINK);
50List return(LIST);
51Format return(FORMAT);
52Name return(NAME);
53Search[tT]ext return(SEARCHTEXT);
54Section[lL]ist return(SECTIONLIST);
55Sorted[lL]ist return(SORTEDLIST);
56Sorted[sS]ection[lL]ist return(SORTEDSECTIONLIST);
57Text[lL]ink return(TEXTLINK);
58Type return(TYPE);
59public return (PUBLIC);
60true return (TRUE);
61false return (FALSE);
62^document return (DOCUMENT);
63^section return (SECTION);
64[iI]con return (ICON);
65[sS]mall[iI]con return (SMALLICON);
66\" {string=NULL;BEGIN(STRINGCOND);}
67<STRINGCOND>{
68 ([^\"\\\n])* {/* append this to our current string EXC NEWLINE */
69 if (string==NULL) string_len=0; else
70 string_len=strlen(string);
71 string=realloc(string,string_len+strlen(yytext)+1);
72 /* +1 is for trailing \0 */
73 strcpy(string+string_len,yytext);
74 }
75 ([^\"\\])*\n {/* append this to our current string - INC NEWLINE */
76 lineno++;
77 if (string==NULL) string_len=0; else
78 string_len=strlen(string);
79 string=realloc(string,string_len+strlen(yytext)+1);
80 /* +1 is for trailing \0 */
81 strcpy(string+string_len,yytext);
82 }
83 "\\"\" |
84 \"\" { /*replace quoted quote with one quote*/
85 string_len=strlen(string);
86 string=realloc(string,string_len+2);
87 string[string_len]='\"';
88 string[string_len+1]='\0';
89 }
90 \" {
91 BEGIN(INITIAL);
92 yylval.string=string;
93 return(STRING);
94 /* note that the string may have long bits of
95 whitespace in it that we could remove. */
96 }
97}
98[[:alnum:]@\.-]+ yylval.string=strdup(yytext);return (DATA);
99(" "|\t) ;
100(\n|\r) lineno++;
101%%
102/******** deleted rules: *******
103en return(EN);
104fr return(FR);
105mi return(MI);
106zh return(ZH);
107de return(DE);
108***************/
109
110
111
112
Note: See TracBrowser for help on using the repository browser.