home *** CD-ROM | disk | FTP | other *** search
- head 1.6;
- access;
- symbols
- stage1:1.6;
- locks; strict;
- comment @ * @;
-
-
- 1.6
- date 94.03.10.21.28.26; author peteric; state Exp;
- branches;
- next 1.5;
-
- 1.5
- date 94.03.01.23.25.36; author peteric; state Exp;
- branches;
- next 1.4;
-
- 1.4
- date 94.02.27.19.33.34; author peteric; state Exp;
- branches;
- next 1.3;
-
- 1.3
- date 94.02.13.16.41.58; author peteric; state Exp;
- branches;
- next 1.2;
-
- 1.2
- date 94.02.12.20.00.19; author peteric; state Exp;
- branches;
- next 1.1;
-
- 1.1
- date 94.02.12.19.52.11; author peteric; state Exp;
- branches;
- next ;
-
-
- desc
- @flex parser for ftree database files.
- @
-
-
- 1.6
- log
- @Multiple pages working!
- @
- text
- @/*************************************************************************
- *
- * $Name$
- *
- * $Author: peteric $
- *
- * $Date: 1994/03/01 23:25:36 $
- *
- * $Revision: 1.5 $
- *
- * Purpose: Flex prser defintion for ftree family tree formatter.
- *
- * $Log: lex.l,v $
- * Revision 1.5 1994/03/01 23:25:36 peteric
- * added missing token ticklen.
- *
- * Revision 1.4 1994/02/27 19:33:34 peteric
- * improved string handling, added new tokens, improved include file debug.
- *
- * Revision 1.3 1994/02/13 16:41:58 peteric
- * added new include file processing, various extra tokens
- * and corrected string rule to stop at newlines.
- *
- * Revision 1.2 1994/02/12 20:00:19 peteric
- * added in comments etc.
- *
- *
- *
- *************************************************************************/
-
- %{
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- #include "parse.h"
- #include "ftree.h"
-
- #define MAX_INCLUDE_DEPTH 10
-
- struct include_frame
- {
- YY_BUFFER_STATE buf;
- char *filename;
- int line;
- };
-
- struct include_frame include_stack[MAX_INCLUDE_DEPTH];
- int include_sp = 0;
- %}
-
- %x INCLUDE QUOTE
-
- DIGIT [0-9]
- SIGN [-+]{0,1}
-
- %%
-
- <INITIAL>include { BEGIN INCLUDE; }
-
- <INCLUDE>[ \t]+
-
- <INCLUDE>\"[^\"\n]+\" {
- static char fbuf[512];
- char *p;
-
- /*
- * extract the filename from the string
- */
- strcpy(fbuf, (char*)yytext+1);
- p = strrchr(fbuf, '\"');
- *p = '\0';
- dbprintf(("include: from line %d of \"%s\" file \"%s\"\n",
- lineno, current_filename, fbuf));
-
- /*
- * check that we can do it!
- */
- if (include_sp >= MAX_INCLUDE_DEPTH)
- {
- errmsg("include statement nested too deeply (>%d)\n", MAX_INCLUDE_DEPTH);
- }
- /*
- * push the current filename/line on the stack & install the
- * new file & up the stack pointer.
- */
- include_stack[include_sp].line = lineno;
- include_stack[include_sp].filename = malloc(strlen(current_filename)+1);
- if (include_stack[include_sp].filename)
- strcpy(include_stack[include_sp].filename, current_filename);
- include_stack[include_sp].buf = YY_CURRENT_BUFFER;
- include_sp++;
-
- /*
- * set up the current details.
- */
- lineno = 1;
- current_filename = fbuf;
- yyin = fopen(fbuf, "r");
- if (!yyin)
- errmsg("cannot open include file \"%s\"\n", fbuf);
- yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
- BEGIN INITIAL;
- }
-
- [Jj]an { yylval.inum = 1; return MONTH; }
-
- [Ff]eb { yylval.inum = 2; return MONTH; }
-
- [Mm]ar { yylval.inum = 3; return MONTH; }
-
- [Aa]pr { yylval.inum = 4; return MONTH; }
-
- [Mm]ay { yylval.inum = 5; return MONTH; }
-
- [Jj]un { yylval.inum = 6; return MONTH; }
-
- [Jj]ul { yylval.inum = 7; return MONTH; }
-
- [Aa]ug { yylval.inum = 8; return MONTH; }
-
- [Ss]ep { yylval.inum = 9; return MONTH; }
-
- [Oo]ct { yylval.inum = 10; return MONTH; }
-
- [Nn]ov { yylval.inum = 11; return MONTH; }
-
- [Dd]ec { yylval.inum = 12; return MONTH; }
-
- [A-Z][0-9]{1,4} {
- yylval.inum = cvid(yytext);
- return ID;
- }
-
- {SIGN}{DIGIT}+ {
- yylval.inum = atoi(yytext);
- return INT;
- }
-
- {SIGN}{DIGIT}+"."{DIGIT}* {
- float f;
- sscanf(yytext, "%f", &f);
- yylval.fnum = f;
- return NUM;
- }
-
- "option" return OPTION;
-
- "{" return OPENBRA;
-
- "}" return CLOSEBRA;
-
- "person" return PERSON;
- "children" return CHILDREN;
- "sex" return SEX;
- "male" return MALE;
- "female" return FEMALE;
- "family"|"lastname"|"surname" return FAMILY;
- "christianname"|"firstname" return FIRSTNAME;
- "living" return LIVING;
- "dead" return DEAD;
- "born" return BORNON;
- "died" return DIEDON;
- "bapt"|"baptised" return BAPTISED;
- "wife" return WIFE;
- "left" return LEFT;
- "right" return RIGHT;
- "husband" return HUSBAND;
- "then" return THEN;
- "marriage" return MARRIAGE;
- "married" return MARRIED;
- "divorced" return DIVORCED;
- "separated" return SEPARATED;
- "widowed" return WIDOWED;
- "occupation" return OCCUPATION;
- "font" return FONT;
- "title" return TITLE;
- "multipage" return MULTIPAGE;
- "vspace" return VSPACE;
- "hspace" return HSPACE;
- "ticklen" return TICKLEN;
- "chartref" return CHARTREF;
- "ident" return IDENT;
- "date" return DATE;
- "symbol" return SYMBOL;
- "pointsize" return POINTSIZE;
- "outputfile" return OUTPUTFILE;
- "pagesize" return PAGESIZE;
- "portrait" return PORTRAIT;
- "landscape" return LANDSCAPE;
- "root" return ROOT;
- "titlebox" return TITLEBOX;
- "notitlebox" return NOTITLEBOX;
- "orientation" return ORIENTATION;
- "," return COMMA;
- "-" return DASH;
- "/" return SLASH;
- "?" return QMARK;
-
- \" {
- BEGIN QUOTE;
- yymore();
- }
-
- <QUOTE>[\"\n] {
- if (yytext[yyleng - 1] == '\n')
- {
- errmsg("unterminated string");
- BEGIN INITIAL;
- return BAD;
- }
- /* dbprintf(("string? = yytext = '%s' ... ", yytext)); */
- fflush(stdout);
- if (yytext[yyleng - 2] == '\\')
- {
- /* dbprintf((" no\n")); */
- yymore();
- }
- else
- {
- static char b[256];
- char *p, *s;
-
- s = yytext+1;
- p = b;
- while(*s)
- {
- if (*s == '\\' && *(s+1) == '"')
- {
- *p++ = '"';
- s+=2;
- }
- else if (*s == '"' && *(s+1) == '\0')
- break;
- else
- *p++ = *s++;
- }
- *p = '\0';
-
- /* dbprintf((" yes: >%s<\n", b)); */
-
- yylval.txt = b;
- BEGIN INITIAL;
- return STRING;
- }
- }
-
- <QUOTE>[^\"\n]* {
- yymore();
- }
-
- ";".*\n { /* comment lines are ignored */ lineno++; }
-
- "\n" { /* increment line count */ lineno++; }
-
- " " { }
-
- " " { }
-
- <INITIAL,INCLUDE>. {
- errmsg("syntax error; character - %c (%d) unexpected.\n", yytext[0], (int)yytext[0]);
- return (BAD);
- }
-
- <<EOF>> {
- if (include_sp == 0)
- {
- yyterminate();
- }
- else
- {
- if (include_stack[include_sp].filename)
- free(include_stack[include_sp].filename);
- include_sp --;
- yy_switch_to_buffer(include_stack[include_sp].buf);
- current_filename = include_stack[include_sp].filename;
- lineno = include_stack[include_sp].line;
- dbprintf(("include: return to line %d of file \"%s\"\n",
- lineno, current_filename));
- }
- }
-
- %%
-
- #ifndef yywrap
- int yywrap()
- {
- return 1;
- }
- #endif
-
- @
-
-
- 1.5
- log
- @added missing token ticklen.
- @
- text
- @d7 1
- a7 1
- * $Date: 1994/02/27 19:33:34 $
- d9 1
- a9 1
- * $Revision: 1.4 $
- d14 3
- a157 1
-
- a159 1
-
- d173 2
- a174 1
- "seperated" return SEPERATED;
- d178 1
- d180 1
- d182 1
- @
-
-
- 1.4
- log
- @improved string handling, added new tokens, improved include file debug.
- @
- text
- @d7 1
- a7 1
- * $Date: 1994/02/13 16:41:58 $
- d9 1
- a9 1
- * $Revision: 1.3 $
- d14 3
- d177 1
- @
-
-
- 1.3
- log
- @added new include file processing, various extra tokens
- and corrected string rule to stop at newlines.
- @
- text
- @d7 1
- a7 1
- * $Date: 1994/02/12 20:00:19 $
- d9 1
- a9 1
- * $Revision: 1.2 $
- d14 4
- d26 2
- a31 2
- int lineno;
- char *current_filename;
- d46 1
- a46 1
- %x INCLUDE
- d67 1
- a67 1
- dbprintf(("include: from line %d of %s file %s\n",
- d75 1
- a75 1
- yyerror("include nested too deeply");
- d95 1
- a95 1
- yyerror("cannot open include file");
- d124 4
- a127 1
- [A-Z][A-Z0-9]+ { yylval.txt = (char*)yytext; return ID; }
- d129 4
- a132 1
- {SIGN}{DIGIT}+ { yylval.inum = atoi(yytext); return INT; }
- d134 6
- a139 1
- {SIGN}{DIGIT}+"."{DIGIT}* { yylval.fnum = atof(yytext); return NUM; }
- d162 2
- d165 1
- d175 2
- d191 4
- a194 7
- \"[^\"\n]*\" {
- static char b[256];
- char *p;
- strcpy(b, (char*)yytext+1);
- p = strrchr(b, '\"');
- *p = '\0';
- yylval.txt = b;
- d196 41
- a236 1
- return STRING;
- d239 3
- a241 1
- ";".*\n { /* comment lines are ok */ lineno++; }
- d243 2
- d251 3
- a253 5
- <INITIAL,INCLUDE>. {
- char buf[32];
- sprintf(buf,"syntax error; character - %c (%d) unexpected.\n", yytext[0], (int)yytext[0]);
- yyerror(buf);
- return (255);
- d256 1
- a256 1
- <<EOF>> {
- d269 1
- a269 1
- dbprintf(("include: return to line %d of file %s\n",
- d275 8
- @
-
-
- 1.2
- log
- @added in comments etc.
- @
- text
- @d5 1
- a5 1
- * $Author$
- d7 1
- a7 1
- * $Date$
- d9 1
- a9 1
- * $Revision$
- d13 4
- a16 1
- * $Log$
- d28 12
- d42 1
- a42 1
- %s OPTIONS
- d45 1
- d49 47
- d122 5
- a126 1
- <INITIAL>{DIGIT}+ { yylval.inum = atoi(yytext); return INT; }
- d128 3
- a130 2
- <OPTIONS>[-+]{DIGIT}*\.{DIGIT}+ { yylval.fnum = atof(yytext); return NUM; }
- <OPTIONS>[-+]{DIGIT}+\.{DIGIT}* { yylval.fnum = atof(yytext); return NUM; }
- d145 1
- a151 1
- "baptised" return BAPTISED;
- d163 2
- a165 10
- "option" {
- BEGIN OPTIONS;
- return OPTION;
- }
-
- "{" return OPENBRA;
- "}" {
- BEGIN INITIAL;
- return CLOSEBRA;
- }
- d171 1
- a171 1
- \"[^"]*\" {
- d182 3
- a184 4
- ";".*\n {
- /* comment lines are ok */
- lineno++;
- }
- d186 1
- a186 4
- "\n" {
- /* increment line count */
- lineno++;
- }
- d188 1
- a188 2
- " " {
- }
- d190 5
- a194 1
- " " {
- d197 16
- a212 3
- . {
- printf("bad - %c (%d)\n", yytext[0], (int)yytext[0]);
- return (255);
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d1 16
- @
-