[10705] | 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 |
|
---|
| 18 | int lineno=1;
|
---|
| 19 | %}
|
---|
| 20 |
|
---|
| 21 | %option noyywrap
|
---|
| 22 |
|
---|
| 23 | COMMENT \#.*(\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);
|
---|
| 39 | maintainer return (MAINTAINER);
|
---|
| 40 | Languages return(LANGUAGES);
|
---|
| 41 | About return(ABOUT);
|
---|
| 42 | Browse return(BROWSE);
|
---|
| 43 | Date[lL]ist return(DATELIST);
|
---|
| 44 | Document[aA]rrows[bB]ottom return(DOCUMENTARROWSBOTTOM);
|
---|
| 45 | Document[bB]uttons return(DOCUMENTBUTTONS);
|
---|
| 46 | Document[hH]eader return(DOCUMENTHEADER);
|
---|
| 47 | Document[iI]mages return(DOCUMENTIMAGES);
|
---|
| 48 | Document[tT]ext return(DOCUMENTTEXT);
|
---|
| 49 | Icon[lL]ink return(ICONLINK);
|
---|
| 50 | List return(LIST);
|
---|
| 51 | Format return(FORMAT);
|
---|
| 52 | Name return(NAME);
|
---|
| 53 | Search[tT]ext return(SEARCHTEXT);
|
---|
| 54 | Section[lL]ist return(SECTIONLIST);
|
---|
| 55 | Sorted[lL]ist return(SORTEDLIST);
|
---|
| 56 | Sorted[sS]ection[lL]ist return(SORTEDSECTIONLIST);
|
---|
| 57 | Text[lL]ink return(TEXTLINK);
|
---|
| 58 | Type return(TYPE);
|
---|
| 59 | public return (PUBLIC);
|
---|
| 60 | true return (TRUE);
|
---|
| 61 | false 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: *******
|
---|
| 103 | en return(EN);
|
---|
| 104 | fr return(FR);
|
---|
| 105 | mi return(MI);
|
---|
| 106 | zh return(ZH);
|
---|
| 107 | de return(DE);
|
---|
| 108 | ***************/
|
---|
| 109 |
|
---|
| 110 |
|
---|
| 111 |
|
---|
| 112 |
|
---|