From 2eae8800306d74d3507eee2464630a085b211779 Mon Sep 17 00:00:00 2001 From: Will Estes Date: Tue, 1 May 2001 20:47:11 +0000 Subject: adding the rest of vern's files --- examples/README | 15 ++ examples/debflex.awk | 119 +++++++++++ examples/manual/ChangeLog | 24 +++ examples/manual/Makefile | 88 ++++++++ examples/manual/README | 17 ++ examples/manual/cat.lex | 45 ++++ examples/manual/dates.lex | 106 ++++++++++ examples/manual/datetest.dat | 28 +++ examples/manual/eof_rules.lex | 65 ++++++ examples/manual/eof_test01.txt | 17 ++ examples/manual/eof_test02.txt | 8 + examples/manual/eof_test03.txt | 7 + examples/manual/expr.lex | 35 ++++ examples/manual/expr.y | 64 ++++++ examples/manual/front.lex | 40 ++++ examples/manual/front.y | 118 +++++++++++ examples/manual/j2t.lex | 442 ++++++++++++++++++++++++++++++++++++++++ examples/manual/myname.lex | 15 ++ examples/manual/myname.txt | 6 + examples/manual/myname2.lex | 19 ++ examples/manual/numbers.lex | 145 +++++++++++++ examples/manual/pas_include.lex | 78 +++++++ examples/manual/pascal.lex | 120 +++++++++++ examples/manual/reject.lex | 12 ++ examples/manual/replace.lex | 33 +++ examples/manual/string1.lex | 98 +++++++++ examples/manual/string2.lex | 94 +++++++++ examples/manual/strtest.dat | 21 ++ examples/manual/unput.lex | 32 +++ examples/manual/user_act.lex | 31 +++ examples/manual/userinit.lex | 30 +++ examples/manual/wc.lex | 122 +++++++++++ examples/manual/yymore.lex | 29 +++ examples/manual/yymore2.lex | 33 +++ examples/manual/yymoretest.dat | 7 + examples/testxxLexer.l | 58 ++++++ 36 files changed, 2221 insertions(+) create mode 100644 examples/README create mode 100644 examples/debflex.awk create mode 100644 examples/manual/ChangeLog create mode 100644 examples/manual/Makefile create mode 100644 examples/manual/README create mode 100644 examples/manual/cat.lex create mode 100644 examples/manual/dates.lex create mode 100644 examples/manual/datetest.dat create mode 100644 examples/manual/eof_rules.lex create mode 100644 examples/manual/eof_test01.txt create mode 100644 examples/manual/eof_test02.txt create mode 100644 examples/manual/eof_test03.txt create mode 100644 examples/manual/expr.lex create mode 100644 examples/manual/expr.y create mode 100644 examples/manual/front.lex create mode 100644 examples/manual/front.y create mode 100644 examples/manual/j2t.lex create mode 100644 examples/manual/myname.lex create mode 100644 examples/manual/myname.txt create mode 100644 examples/manual/myname2.lex create mode 100644 examples/manual/numbers.lex create mode 100644 examples/manual/pas_include.lex create mode 100644 examples/manual/pascal.lex create mode 100644 examples/manual/reject.lex create mode 100644 examples/manual/replace.lex create mode 100644 examples/manual/string1.lex create mode 100644 examples/manual/string2.lex create mode 100644 examples/manual/strtest.dat create mode 100644 examples/manual/unput.lex create mode 100644 examples/manual/user_act.lex create mode 100644 examples/manual/userinit.lex create mode 100644 examples/manual/wc.lex create mode 100644 examples/manual/yymore.lex create mode 100644 examples/manual/yymore2.lex create mode 100644 examples/manual/yymoretest.dat create mode 100644 examples/testxxLexer.l (limited to 'examples') diff --git a/examples/README b/examples/README new file mode 100644 index 0000000..46f542b --- /dev/null +++ b/examples/README @@ -0,0 +1,15 @@ +This directory contains some examples of what you can do with +flex. These files are not tested regularly so you might have to tinker +a bit before they work for you. Updates, new files and patches are welcome. + + - debflex.awk, an awk script for anotating flex debug output. + It presently only works with gawk and mawk, not with "old" + or "new" awk. + + - testxxLexer.l, a sample C++ program that uses flex's scanner + class option ("-+"). + + - fastwc/, a subdirectory containing examples of how to use flex + to write progressively higher-performance versions of the Unix + "wc" utility. This certainly should work with 2.5, but hasn't + been tested. diff --git a/examples/debflex.awk b/examples/debflex.awk new file mode 100644 index 0000000..b1eda49 --- /dev/null +++ b/examples/debflex.awk @@ -0,0 +1,119 @@ +# Clarify the flex debug trace by substituting first line of each rule. +# Francois Pinard , July 1990. +# +# Rewritten to process correctly \n's in scanner input. +# BEGIN section modified to correct a collection of rules. +# Michal Jaegermann , December 1993 +# +# Sample usage: +# flex -d PROGRAM.l +# gcc -o PROGRAM PROGRAM.c -lfl +# PROGRAM 2>&1 | gawk -f debflex.awk PROGRAM.l +# +# (VP's note: this script presently does not work with either "old" or +# "new" awk; fixes so it does will be welcome) + +BEGIN { + # Insure proper usage. + + if (ARGC != 2) { + print "usage: gawk -f debflex.awk FLEX_SOURCE + +char **names = NULL; +int current = 1; +%} + +%% +<> { + current += 1; + if(names[current] != NULL){ + yyin = fopen(names[current],"r"); + if(yyin == NULL){ + fprintf(stderr,"cat: unable to open %s\n", + names[current]); + yyterminate(); + } + YY_NEW_FILE; + } else { + yyterminate(); + } + } +%% + +int main(int argc, char **argv) +{ + if(argc < 2){ + fprintf(stderr,"Usage: cat files....\n"); + exit(1); + } + names = argv; + + yyin = fopen(names[current],"r"); + if(yyin == NULL){ + fprintf(stderr,"cat: unable to open %s\n", + names[current]); + yyterminate(); + } + + yylex(); +} diff --git a/examples/manual/dates.lex b/examples/manual/dates.lex new file mode 100644 index 0000000..9429e1d --- /dev/null +++ b/examples/manual/dates.lex @@ -0,0 +1,106 @@ +/* + * dates.lex: An example of using start states to + * distinguish between different date formats. + */ + +%{ +#include + +char month[20],dow[20],day[20],year[20]; + +%} + +skip of|the|[ \t,]* + +mon (mon(day)?) +tue (tue(sday)?) +wed (wed(nesday)?) +thu (thu(rsday)?) +fri (fri(day)?) +sat (sat(urday)?) +sun (sun(day)?) + +day_of_the_week ({mon}|{tue}|{wed}|{thu}|{fri}|{sat}|{sun}) + +jan (jan(uary)?) +feb (feb(ruary)?) +mar (mar(ch)?) +apr (apr(il)?) +may (may) +jun (jun(e)?) +jul (jul(y)?) +aug (aug(ust)?) +sep (sep(tember)?) +oct (oct(ober)?) +nov (nov(ember)?) +dec (dec(ember)?) + +first_half ({jan}|{feb}|{mar}|{apr}|{may}|{jun}) +second_half ({jul}|{aug}|{sep}|{oct}|{nov}|{dec}) +month {first_half}|{second_half} + +nday [1-9]|[1-2][0-9]|3[0-1] +nmonth [1-9]|1[0-2] +nyear [0-9]{1,4} + +year_ext (ad|AD|bc|BC)? +day_ext (st|nd|rd|th)? + +%s LONG SHORT +%s DAY DAY_FIRST YEAR_FIRST YEAR_LAST YFMONTH YLMONTH + +%% + + /* the default is month-day-year */ + +{day_of_the_week} strcpy(dow,yytext); +{month} strcpy(month,yytext); BEGIN(DAY); + + /* handle the form: day-month-year */ + +{nday}{day_ext} strcpy(day,yytext); BEGIN(DAY_FIRST); +{month} strcpy(month,yytext); BEGIN(LONG); +{nday}{day_ext} strcpy(day,yytext); BEGIN(LONG); + +{nyear}{year_ext} { + printf("Long:\n"); + printf(" DOW : %s \n",dow); + printf(" Day : %s \n",day); + printf(" Month : %s \n",month); + printf(" Year : %s \n",yytext); + strcpy(dow,""); + strcpy(day,""); + strcpy(month,""); + } + + /* handle dates of the form: day-month-year */ + +{nday} strcpy(day,yytext); BEGIN(YEAR_LAST); +{nmonth} strcpy(month,yytext);BEGIN(YLMONTH); +{nyear} strcpy(year,yytext); BEGIN(SHORT); + + /* handle dates of the form: year-month-day */ + +{nyear} strcpy(year,yytext); BEGIN(YEAR_FIRST); +{nmonth} strcpy(month,yytext);BEGIN(YFMONTH); +{nday} strcpy(day,yytext); BEGIN(SHORT); + + +\n { + printf("Short:\n"); + printf(" Day : %s \n",day); + printf(" Month : %s \n",month); + printf(" Year : %s \n",year); + strcpy(year,""); + strcpy(day,""); + strcpy(month,""); + } + +long\n BEGIN(LONG); +short\n BEGIN(SHORT); + +{skip}* +\n +. + + diff --git a/examples/manual/datetest.dat b/examples/manual/datetest.dat new file mode 100644 index 0000000..427f407 --- /dev/null +++ b/examples/manual/datetest.dat @@ -0,0 +1,28 @@ +short +1989:12:23 +1989:11:12 +23:12:1989 +11:12:1989 +1989/12/23 +1989/11/12 +23/12/1989 +11/12/1989 +1989-12-23 +1989-11-12 +23-12-1989 +11-12-1989 +long +Friday the 5th of January, 1989 +Friday, 5th of January, 1989 +Friday, January 5th, 1989 +Fri, January 5th, 1989 +Fri, Jan 5th, 1989 +Fri, Jan 5, 1989 +FriJan 5, 1989 +FriJan5, 1989 +FriJan51989 +Jan51989 + + + + diff --git a/examples/manual/eof_rules.lex b/examples/manual/eof_rules.lex new file mode 100644 index 0000000..b575f2c --- /dev/null +++ b/examples/manual/eof_rules.lex @@ -0,0 +1,65 @@ +/* + * eof_rules.lex : An example of using multiple buffers + * EOF rules, and start states + */ + +%{ + +#define MAX_NEST 10 + +YY_BUFFER_STATE include_stack[MAX_NEST]; +int include_count = -1; + +%} + + +%x INCLUDE + +%% + +^"#include"[ \t]*\" BEGIN(INCLUDE); +\" BEGIN(INITIAL); +[^\"]+ { /* get the include file name */ + if ( include_count >= MAX_NEST){ + fprintf( stderr, "Too many include files" ); + exit( 1 ); + } + + include_stack[++include_count] = YY_CURRENT_BUFFER; + + yyin = fopen( yytext, "r" ); + if ( ! yyin ){ + fprintf( stderr, "Unable to open \"%s\"\n",yytext); + exit( 1 ); + } + + yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE)); + + BEGIN(INITIAL); + } +<> + { + fprintf( stderr, "EOF in include" ); + yyterminate(); + } +<> { + if ( include_count <= 0 ){ + yyterminate(); + } else { + yy_delete_buffer(include_stack[include_count--] ); + yy_switch_to_buffer(include_stack[include_count] ); + BEGIN(INCLUDE); + } + } +[a-z]+ ECHO; +.|\n ECHO; + + + + + + + + + + diff --git a/examples/manual/eof_test01.txt b/examples/manual/eof_test01.txt new file mode 100644 index 0000000..ec5f083 --- /dev/null +++ b/examples/manual/eof_test01.txt @@ -0,0 +1,17 @@ +This is test file #1 + +------------------------------------------------- + +We will now include test #2 in a standard way. + +#include "eof_test02.txt" + +------------------------------------------------- + +And now we will include test # 2 with a different +format + +#include "eof_test02.txt" +------------------------------------------------- + +and this is the end of the test. diff --git a/examples/manual/eof_test02.txt b/examples/manual/eof_test02.txt new file mode 100644 index 0000000..19f52cf --- /dev/null +++ b/examples/manual/eof_test02.txt @@ -0,0 +1,8 @@ +INCLUDE #2 + +This is the second file that will +be included. + +>>> Foo are GNU? + +#include "eof_test03.txt" diff --git a/examples/manual/eof_test03.txt b/examples/manual/eof_test03.txt new file mode 100644 index 0000000..e737879 --- /dev/null +++ b/examples/manual/eof_test03.txt @@ -0,0 +1,7 @@ +INCLUDE #3 + +This is the third file that will +be included. + +>>> echo "I am `whoami`!!" + diff --git a/examples/manual/expr.lex b/examples/manual/expr.lex new file mode 100644 index 0000000..9adfcaa --- /dev/null +++ b/examples/manual/expr.lex @@ -0,0 +1,35 @@ +/* + * expr.lex : Scanner for a simple + * expression parser. + */ + +%{ +#include "y.tab.h" + +%} + +%% + +[0-9]+ { yylval.val = atol(yytext); + return(NUMBER); + } +[0-9]+\.[0-9]+ { + sscanf(yytext,"%f",&yylval.val); + return(NUMBER); + } +"+" return(PLUS); +"-" return(MINUS); +"*" return(MULT); +"/" return(DIV); +"^" return(EXPON); +"(" return(LB); +")" return(RB); +\n return(EOL); +[\t ]* /* throw away whitespace */ +. { yyerror("Illegal character"); + return(EOL); + } +%% + + + diff --git a/examples/manual/expr.y b/examples/manual/expr.y new file mode 100644 index 0000000..1ac3092 --- /dev/null +++ b/examples/manual/expr.y @@ -0,0 +1,64 @@ +/* + * expr.y : A simple yacc expression parser + * Based on the Bison manual example. + */ + +%{ +#include +#include + +%} + +%union { + float val; +} + +%token NUMBER +%token PLUS MINUS MULT DIV EXPON +%token EOL +%token LB RB + +%left MINUS PLUS +%left MULT DIV +%right EXPON + +%type exp NUMBER + +%% +input : + | input line + ; + +line : EOL + | exp EOL { printf("%g\n",$1);} + +exp : NUMBER { $$ = $1; } + | exp PLUS exp { $$ = $1 + $3; } + | exp MINUS exp { $$ = $1 - $3; } + | exp MULT exp { $$ = $1 * $3; } + | exp DIV exp { $$ = $1 / $3; } + | MINUS exp %prec MINUS { $$ = -$2; } + | exp EXPON exp { $$ = pow($1,$3);} + | LB exp RB { $$ = $2; } + ; + +%% + +yyerror(char *message) +{ + printf("%s\n",message); +} + +int main(int argc, char *argv[]) +{ + yyparse(); + return(0); +} + + + + + + + + diff --git a/examples/manual/front.lex b/examples/manual/front.lex new file mode 100644 index 0000000..449cb00 --- /dev/null +++ b/examples/manual/front.lex @@ -0,0 +1,40 @@ +%{ +#include +#include +#include "y.tab.h" /* this comes from bison */ + +#define TRUE 1 +#define FALSE 0 + +#define copy_and_return(token_type) { strcpy(yylval.name,yytext); \ + return(token_type); } + +int yylexlinenum = 0; /* so we can count lines */ +%} + +%% + /* Lexical scanning rules begin from here. */ + +MEN|WOMEN|STOCKS|TREES copy_and_return(NOUN) +MISTAKES|GNUS|EMPLOYEES copy_and_return(NOUN) +LOSERS|USERS|CARS|WINDOWS copy_and_return(NOUN) + +DATABASE|NETWORK|FSF|GNU copy_and_return(PROPER_NOUN) +COMPANY|HOUSE|OFFICE|LPF copy_and_return(PROPER_NOUN) + +THE|THIS|THAT|THOSE copy_and_return(DECLARATIVE) + +ALL|FIRST|LAST copy_and_return(CONDITIONAL) + +FIND|SEARCH|SORT|ERASE|KILL copy_and_return(VERB) +ADD|REMOVE|DELETE|PRINT copy_and_return(VERB) + +QUICKLY|SLOWLY|CAREFULLY copy_and_return(ADVERB) + +IN|AT|ON|AROUND|INSIDE|ON copy_and_return(POSITIONAL) + +"." return(PERIOD); +"\n" yylexlinenum++; return(NEWLINE); +. +%% + diff --git a/examples/manual/front.y b/examples/manual/front.y new file mode 100644 index 0000000..77b5ca1 --- /dev/null +++ b/examples/manual/front.y @@ -0,0 +1,118 @@ +/* C code supplied at the beginning of the file. */ + +%{ + +#include +#include + +extern int yylexlinenum; /* these are in YYlex */ +extern char *yytext; /* current token */ + + +%} + +/* Keywords and reserved words begin here. */ + +%union{ /* this is the data union */ + char name[128]; /* names */ +} + +/*-------------------- the reserved words -----------------------------*/ + +%token PERIOD +%token NEWLINE +%token POSITIONAL + +%token VERB +%token ADVERB + +%token PROPER_NOUN +%token NOUN + +%token DECLARATIVE +%token CONDITIONAL + + +%type declarative +%type verb_phrase +%type noun_phrase +%type position_phrase +%type adverb + +%type POSITIONAL VERB ADVERB PROPER_NOUN +%type NOUN DECLARATIVE CONDITIONAL + +%% + +sentence_list : sentence + | sentence_list NEWLINE sentence + ; + + +sentence : verb_phrase noun_phrase position_phrase adverb period + { + printf("I understand that sentence.\n"); + printf("VP = %s \n",$1); + printf("NP = %s \n",$2); + printf("PP = %s \n",$3); + printf("AD = %s \n",$4); + } + | { yyerror("That's a strange sentence !!"); } + ; + +position_phrase : POSITIONAL declarative PROPER_NOUN + { + sprintf($$,"%s %s %s",$1,$2,$3); + } + | /* empty */ { strcpy($$,""); } + ; + + +verb_phrase : VERB { strcpy($$,$1); strcat($$," "); } + | adverb VERB + { + sprintf($$,"%s %s",$1,$2); + } + ; + +adverb : ADVERB { strcpy($$,$1); } + | /* empty */ { strcpy($$,""); } + ; + +noun_phrase : DECLARATIVE NOUN + { + sprintf($$,"%s %s",$1,$2); + } + | CONDITIONAL declarative NOUN + { + sprintf($$,"%s %s %s",$1,$2,$3); + } + | NOUN { strcpy($$,$1); strcat($$," "); } + ; + +declarative : DECLARATIVE { strcpy($$,$1); } + | /* empty */ { strcpy($$,""); } + ; + +period : /* empty */ + | PERIOD + ; + + +%% + +/* Supplied main() and yyerror() functions. */ + +int main(int argc, char *argv[]) +{ + yyparse(); /* parse the file */ + return(0); +} + +int yyerror(char *message) +{ + extern FILE *yyout; + + fprintf(yyout,"\nError at line %5d. (%s) \n", + yylexlinenum,message); +} diff --git a/examples/manual/j2t.lex b/examples/manual/j2t.lex new file mode 100644 index 0000000..08fbd21 --- /dev/null +++ b/examples/manual/j2t.lex @@ -0,0 +1,442 @@ +/* + * j2t.lex : An example of the use (possibly abuse!) + * of start states. + */ + +%{ +#define MAX_STATES 1024 +#define TRUE 1 +#define FALSE 0 + +#define CHAPTER "@chapter" +#define SECTION "@section" +#define SSECTION "@subsection" +#define SSSECTION "@subsubsection" + +int states[MAX_STATES]; +int statep = 0; + +int need_closing = FALSE; + +char buffer[YY_BUF_SIZE]; + +extern char *yytext; + +/* + * set up the head of the *.texinfo file the program + * will produce. This is a standard texinfo header. + */ + +void print_header(void) +{ + printf("\\input texinfo @c -*-texinfo-*-\n"); + printf("@c %c**start of header\n",'%'); + printf("@setfilename jargon.info\n"); + printf("@settitle The New Hackers Dictionary\n"); + printf("@synindex fn cp\n"); + printf("@synindex vr cp\n"); + printf("@c %c**end of header\n",'%'); + printf("@setchapternewpage odd\n"); + printf("@finalout\n"); + printf("@c @smallbook\n"); + printf("\n"); + printf("@c ==========================================================\n\n"); + printf("@c This file was produced by j2t. Any mistakes are *not* the\n"); + printf("@c fault of the jargon file editors. \n"); + printf("@c ==========================================================\n\n"); + printf("@titlepage\n"); + printf("@title The New Hackers Dictionary\n"); + printf("@subtitle Version 2.9.10\n"); + printf("@subtitle Generated by j2t\n"); + printf("@author Eric S. Raymond, Guy L. Steel, Mark Crispin et al.\n"); + printf("@end titlepage\n"); + printf("@page\n"); + printf("\n@c ==========================================================\n"); + printf("\n\n"); + printf("@unnumbered Preface\n"); + printf("@c *******\n"); +} + +/* + * create the tail of the texinfo file produced. + */ + +void print_trailer(void) +{ + printf("\n@c ==========================================================\n"); + printf("@contents\n"); /* print the table of contents */ + printf("@bye\n\n"); +} + +/* + * write an underline under a section + * or chapter so we can find it later. + */ + +void write_underline(int len, int space, char ch) +{ + int loop; + + printf("@c "); + + for(loop=3; loop"@" printf("@@"); +"{" printf("@{"); +"}" printf("@}"); + + /* + * reproduce @example code + */ + +":"\n+[^\n0-9*]+\n" "[^ ] { + int loop; + int len; + int cnt; + + printf(":\n\n@example \n"); + strcpy(buffer,yytext); + len = strlen(buffer); + cnt = 0; + for(loop=len; loop > 0;loop--){ + if(buffer[loop] == '\n') + cnt++; + if(cnt == 2) + break; + } + yyless(loop+1); + statep++; + states[statep] = EXAMPLE2; + BEGIN(EXAMPLE2); + } +^\n { + printf("@end example\n\n"); + statep--; + BEGIN(states[statep]); + } + + /* + * repoduce @enumerate lists + */ + +":"\n+[ \t]*[0-9]+"." { + int loop; + int len; + + printf(":\n\n@enumerate \n"); + strcpy(buffer,yytext); + len = strlen(buffer); + for(loop=len; loop > 0;loop--){ + if(buffer[loop] == '\n') + break; + } + yyless(loop); + statep++; + states[statep] = ENUM; + BEGIN(ENUM); + } + +"@" printf("@@"); +":"\n+" "[^0-9] { + printf(":\n\n@example\n"); + statep++; + states[statep] = EXAMPLE; + BEGIN(EXAMPLE); + } + + +\n[ \t]+[0-9]+"." { + printf("\n\n@item "); + } +^[^ ] | +\n\n\n[ \t]+[^0-9] { + printf("\n\n@end enumerate\n\n"); + statep--; + BEGIN(states[statep]); + } + + /* + * reproduce one kind of @itemize list + */ + +":"\n+":" { + int loop; + int len; + + printf(":\n\n@itemize @bullet \n"); + yyless(2); + statep++; + states[statep] = LITEM2; + BEGIN(LITEM2); + } +^":".+":" { + (void)check_and_convert(&yytext[1]); + buffer[strlen(buffer)-1]='\0'; + printf("@item @b{%s:}\n",buffer); + } + +\n\n\n+[^:\n] { + printf("\n\n@end itemize\n\n"); + ECHO; + statep--; + BEGIN(states[statep]); + } + + /* + * create a list out of the revision history part. + * We need the "Version" for this because it + * clashes with other rules otherwise. + */ + +:[\n]+"Version"[^:\n*]+":" { + int loop; + int len; + + printf(":\n\n@itemize @bullet \n"); + strcpy(buffer,yytext); + len = strlen(buffer); + for(loop=len; loop > 0;loop--){ + if(buffer[loop] == '\n') + break; + } + yyless(loop); + statep++; + states[statep] = LITEM; + BEGIN(LITEM); + } +^.+":" { + (void)check_and_convert(yytext); + buffer[strlen(buffer)-1]='\0'; + printf("@item @b{%s}\n\n",buffer); + } + +^[^:\n]+\n\n[^:\n]+\n { + int loop; + + strcpy(buffer,yytext); + for(loop=0; buffer[loop] != '\n'; loop++); + buffer[loop] = '\0'; + printf("%s\n",buffer); + printf("@end itemize\n\n"); + printf("%s",&buffer[loop+1]); + statep--; + BEGIN(states[statep]); + } + + /* + * reproduce @itemize @bullet lists + */ + +":"\n[ ]*"*" { + int loop; + int len; + + printf(":\n\n@itemize @bullet \n"); + len = strlen(buffer); + for(loop=0; loop < len;loop++){ + if(buffer[loop] == '\n') + break; + } + yyless((len-loop)+2); + statep++; + states[statep] = BITEM; + BEGIN(BITEM); + } + +^" "*"*" { + printf("@item"); + statep++; + states[statep] = BITEM_ITEM; + BEGIN(BITEM_ITEM); + } +"@" printf("@@"); +^\n { + printf("@end itemize\n\n"); + statep--; + BEGIN(states[statep]); + } +[^\:]* { + printf(" @b{%s}\n\n",check_and_convert(yytext)); + } +":" { + statep--; + BEGIN(states[statep]); + } + + /* + * recreate @chapter, @section etc. + */ + +^:[^:]* { + (void)check_and_convert(&yytext[1]); + statep++; + states[statep] = HEADING; + BEGIN(HEADING); + } +:[^\n] { + printf("@item @b{%s}\n",buffer); + write_underline(strlen(buffer),6,'~'); + statep--; + BEGIN(states[statep]); + } +:\n"*"* { + if(need_closing == TRUE){ + printf("@end table\n\n\n"); + need_closing = FALSE; + } + printf("@chapter %s\n",buffer); + write_underline(strlen(buffer),9,'*'); + statep--; + BEGIN(states[statep]); + } +:\n"="* { + if(need_closing == TRUE){ + printf("@end table\n\n\n"); + need_closing = FALSE; + } + printf("@section %s\n",buffer); + write_underline(strlen(buffer),9,'='); + statep--; + BEGIN(states[statep]); + } +"@" printf("@@"); +:\n"-"* { + if(need_closing == TRUE){ + printf("@end table\n\n\n"); + need_closing = FALSE; + } + printf("@subsection %s\n",buffer); + write_underline(strlen(buffer),12,'-'); + statep--; + BEGIN(states[statep]); + } + + /* + * recreate @example text + */ + +^" " { + printf("@example\n"); + statep++; + states[statep] = EXAMPLE; + BEGIN(EXAMPLE); + } +^" " +. ECHO; + +%% + +/* + * initialise and go. + */ + +int main(int argc, char *argv[]) +{ + states[0] = INITIAL; + statep = 0; + print_header(); + yylex(); + print_trailer(); + return(0); +} + + + diff --git a/examples/manual/myname.lex b/examples/manual/myname.lex new file mode 100644 index 0000000..2e36095 --- /dev/null +++ b/examples/manual/myname.lex @@ -0,0 +1,15 @@ +/* + * + * myname.lex : A sample Flex program + * that does token replacement. + */ + +%% + +%NAME { printf("%s",getenv("LOGNAME")); } +%HOST { printf("%s",getenv("HOST")); } +%HOSTTYPE { printf("%s",getenv("HOSTTYPE"));} +%HOME { printf("%s",getenv("HOME")); } + +%% + diff --git a/examples/manual/myname.txt b/examples/manual/myname.txt new file mode 100644 index 0000000..0631840 --- /dev/null +++ b/examples/manual/myname.txt @@ -0,0 +1,6 @@ +Hello, my name name is %NAME. Actually +"%NAME" isn't my real name, it is the +alias I use when I'm on %HOST, which +is the %HOSTTYPE I use. My HOME +directory is %HOME. + diff --git a/examples/manual/myname2.lex b/examples/manual/myname2.lex new file mode 100644 index 0000000..cef55d8 --- /dev/null +++ b/examples/manual/myname2.lex @@ -0,0 +1,19 @@ +/* + * myname2.lex : A sample Flex program + * that does token replacement. + */ + +%{ +#include +%} + +%x STRING +%% +\" ECHO; BEGIN(STRING); +[^\"\n]* ECHO; +\" ECHO; BEGIN(INITIAL); + +%NAME { printf("%s",getenv("LOGNAME")); } +%HOST { printf("%s",getenv("HOST")); } +%HOSTTYPE { printf("%s",getenv("HOSTTYPE"));} +%HOME { printf("%s",getenv("HOME")); } diff --git a/examples/manual/numbers.lex b/examples/manual/numbers.lex new file mode 100644 index 0000000..6484d6e --- /dev/null +++ b/examples/manual/numbers.lex @@ -0,0 +1,145 @@ +/* + * numbers.lex : An example of the definitions and techniques + * for scanning numbers + */ + +%{ +#include + +#define UNSIGNED_LONG_SYM 1 +#define SIGNED_LONG_SYM 2 +#define UNSIGNED_SYM 3 +#define SIGNED_SYM 4 +#define LONG_DOUBLE_SYM 5 +#define FLOAT_SYM 6 + +union _yylval { + long double ylong_double; + float yfloat; + unsigned long yunsigned_long; + unsigned yunsigned; + long ysigned_long; + int ysigned; +} yylval; + +%} + +digit [0-9] +hex_digit [0-9a-fA-F] +oct_digit [0-7] + +exponent [eE][+-]?{digit}+ +i {digit}+ +float_constant ({i}\.{i}?|{i}?\.{i}){exponent}? +hex_constant 0[xX]{hex_digit}+ +oct_constant 0{oct_digit}* +int_constant {digit}+ +long_ext [lL] +unsigned_ext [uU] +float_ext [fF] +ulong_ext {long_ext}{unsigned_ext}|{unsigned_ext}{long_ext} + +%% + +{hex_constant}{ulong_ext} { /* we need to skip the "0x" part */ + sscanf(&yytext[2],"%lx",&yylval.yunsigned_long); + return(UNSIGNED_LONG_SYM); + } +{hex_constant}{long_ext} { + sscanf(&yytext[2],"%lx",&yylval.ysigned_long); + return(SIGNED_LONG_SYM); + } +{hex_constant}{unsigned_ext} { + sscanf(&yytext[2],"%x",&yylval.yunsigned); + return(UNSIGNED_SYM); + } +{hex_constant} { /* use %lx to protect against overflow */ + sscanf(&yytext[2],"%lx",&yylval.ysigned_long); + return(SIGNED_LONG_SYM); + } +{oct_constant}{ulong_ext} { + sscanf(yytext,"%lo",&yylval.yunsigned_long); + return(UNSIGNED_LONG_SYM); + } +{oct_constant}{long_ext} { + sscanf(yytext,"%lo",&yylval.ysigned_long); + return(SIGNED_LONG_SYM); + } +{oct_constant}{unsigned_ext} { + sscanf(yytext,"%o",&yylval.yunsigned); + return(UNSIGNED_SYM); + } +{oct_constant} { /* use %lo to protect against overflow */ + sscanf(yytext,"%lo",&yylval.ysigned_long); + return(SIGNED_LONG_SYM); + } +{int_constant}{ulong_ext} { + sscanf(yytext,"%ld",&yylval.yunsigned_long); + return(UNSIGNED_LONG_SYM); + } +{int_constant}{long_ext} { + sscanf(yytext,"%ld",&yylval.ysigned_long); + return(SIGNED_LONG_SYM); + } +{int_constant}{unsigned_ext} { + sscanf(yytext,"%d",&yylval.yunsigned); + return(UNSIGNED_SYM); + } +{int_constant} { /* use %ld to protect against overflow */ + sscanf(yytext,"%ld",&yylval.ysigned_long); + return(SIGNED_LONG_SYM); + } +{float_constant}{long_ext} { + sscanf(yytext,"%lf",&yylval.ylong_double); + return(LONG_DOUBLE_SYM); + } +{float_constant}{float_ext} { + sscanf(yytext,"%f",&yylval.yfloat); + return(FLOAT_SYM); + } +{float_constant} { /* use %lf to protect against overflow */ + sscanf(yytext,"%lf",&yylval.ylong_double); + return(LONG_DOUBLE_SYM); + } +%% + +int main(void) +{ + int code; + + while((code = yylex())){ + printf("yytext : %s\n",yytext); + switch(code){ + case UNSIGNED_LONG_SYM: + printf("Type of number : UNSIGNED LONG\n"); + printf("Value of number : %lu\n",yylval.yunsigned_long); + break; + case SIGNED_LONG_SYM: + printf("Type of number : SIGNED LONG\n"); + printf("Value of number : %ld\n",yylval.ysigned_long); + break; + case UNSIGNED_SYM: + printf("Type of number : UNSIGNED\n"); + printf("Value of number : %u\n",yylval.yunsigned); + break; + case SIGNED_SYM: + printf("Type of number : SIGNED\n"); + printf("Value of number : %d\n",yylval.ysigned); + break; + case LONG_DOUBLE_SYM: + printf("Type of number : LONG DOUBLE\n"); + printf("Value of number : %lf\n",yylval.ylong_double); + break; + case FLOAT_SYM: + printf("Type of number : FLOAT\n"); + printf("Value of number : %f\n",yylval.yfloat); + break; + default: + printf("Type of number : UNDEFINED\n"); + printf("Value of number : UNDEFINED\n"); + break; + } + } + return(0); +} + diff --git a/examples/manual/pas_include.lex b/examples/manual/pas_include.lex new file mode 100644 index 0000000..58cf590 --- /dev/null +++ b/examples/manual/pas_include.lex @@ -0,0 +1,78 @@ +/* + * eof_rules.lex : An example of using multiple buffers + * EOF rules, and start states + */ + +%{ + +#define MAX_NEST 10 + +YY_BUFFER_STATE include_stack[MAX_NEST]; +int include_count = -1; + +%} + + +%x INCLUDE +%x COMMENT + + +%% + +"{" BEGIN(COMMENT); + +"}" BEGIN(INITIAL); +"$include"[ \t]*"(" BEGIN(INCLUDE); +[ \t]* /* skip whitespace */ + +")" BEGIN(COMMENT); +[ \t]* /* skip whitespace */ +[^ \t\n() ]+ { /* get the include file name */ + if ( include_count >= MAX_NEST){ + fprintf( stderr, "Too many include files" ); + exit( 1 ); + } + + include_stack[++include_count] = YY_CURRENT_BUFFER; + + yyin = fopen( yytext, "r" ); + if ( ! yyin ){ + fprintf( stderr, "Unable to open %s",yytext); + exit( 1 ); + } + + yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE)); + + BEGIN(INITIAL); + } +<> + { + fprintf( stderr, "EOF in include" ); + yyterminate(); + } +<> + { + fprintf( stderr, "EOF in comment" ); + yyterminate(); + } +<> { + if ( include_count <= 0 ){ + yyterminate(); + } else { + yy_delete_buffer(include_stack[include_count--] ); + yy_switch_to_buffer(include_stack[include_count] ); + BEGIN(INCLUDE); + } + } +[a-z]+ ECHO; +.|\n ECHO; + + + + + + + + + + diff --git a/examples/manual/pascal.lex b/examples/manual/pascal.lex new file mode 100644 index 0000000..d406bbe --- /dev/null +++ b/examples/manual/pascal.lex @@ -0,0 +1,120 @@ +/* + * pascal.lex: An example PASCAL scanner + * + */ + +%{ +#include +#include "y.tab.h" + +int line_number = 0; + +void yyerror(char *message); + +%} + +%x COMMENT1 COMMENT2 + +white_space [ \t]* +digit [0-9] +alpha [A-Za-z_] +alpha_num ({alpha}|{digit}) +hex_digit [0-9A-F] +identifier {alpha}{alpha_num}* +unsigned_integer {digit}+ +hex_integer ${hex_digit}{hex_digit}* +exponent e[+-]?{digit}+ +i {unsigned_integer} +real ({i}\.{i}?|{i}?\.{i}){exponent}? +string \'([^'\n]|\'\')+\' +bad_string \'([^'\n]|\'\')+ + +%% + +"{" BEGIN(COMMENT1); +[^}\n]+ +\n ++line_number; +<> yyerror("EOF in comment"); +"}" BEGIN(INITIAL); + +"(*" BEGIN(COMMENT2); +[^)*\n]+ +\n ++line_number; +<> yyerror("EOF in comment"); +"*)" BEGIN(INITIAL); +[*)] + + /* note that FILE and BEGIN are already + * defined in FLEX or C so they can't + * be used. This can be overcome in + * a cleaner way by defining all the + * tokens to start with TOK_ or some + * other prefix. + */ + +and return(AND); +array return(ARRAY); +begin return(_BEGIN); +case return(CASE); +const return(CONST); +div return(DIV); +do return(DO); +downto return(DOWNTO); +else return(ELSE); +end return(END); +file return(_FILE); +for return(FOR); +function return(FUNCTION); +goto return(GOTO); +if return(IF); +in return(IN); +label return(LABEL); +mod return(MOD); +nil return(NIL); +not return(NOT); +of return(OF); +packed return(PACKED); +procedure return(PROCEDURE); +program return(PROGRAM); +record return(RECORD); +repeat return(REPEAT); +set return(SET); +then return(THEN); +to return(TO); +type return(TYPE); +until return(UNTIL); +var return(VAR); +while return(WHILE); +with return(WITH); + +"<="|"=<" return(LEQ); +"=>"|">=" return(GEQ); +"<>" return(NEQ); +"=" return(EQ); + +".." return(DOUBLEDOT); + +{unsigned_integer} return(UNSIGNED_INTEGER); +{real} return(REAL); +{hex_integer} return(HEX_INTEGER); +{string} return{STRING}; +{bad_string} yyerror("Unterminated string"); + +{identifier} return(IDENTIFIER); + +[*/+\-,^.;:()\[\]] return(yytext[0]); + +{white_space} /* do nothing */ +\n line_number += 1; +. yyerror("Illegal input"); + +%% + +void yyerror(char *message) +{ + fprintf(stderr,"Error: \"%s\" in line %d. Token = %s\n", + message,line_number,yytext); + exit(1); +} + + diff --git a/examples/manual/reject.lex b/examples/manual/reject.lex new file mode 100644 index 0000000..a7b817f --- /dev/null +++ b/examples/manual/reject.lex @@ -0,0 +1,12 @@ +/* + * reject.lex: An example of REJECT and unput() + * misuse. + */ + +%% +UNIX { + unput('U'); unput('N'); unput('G'); unput('\0'); + REJECT; + } +GNU printf("GNU is Not Unix!\n"); +%% diff --git a/examples/manual/replace.lex b/examples/manual/replace.lex new file mode 100644 index 0000000..c5c8d87 --- /dev/null +++ b/examples/manual/replace.lex @@ -0,0 +1,33 @@ +/* + * replace.lex : A simple filter for renaming + * parts of flex of bison generated + * scanners or parsers. + */ + +%{ +#include + +char lower_replace[1024]; +char upper_replace[1024]; + +%} + +%% + +"yy" printf("%s",lower_replace); +"YY" printf("%s",upper_replace); +, ECHO; + +%% + +int main(int argc, char *argv[]) +{ + if(argc < 2){ + printf("Usage %s lower UPPER\n",argv[0]); + exit(1); + } + strcpy(lower_replace,argv[1]); + strcpy(upper_replace,argv[2]); + yylex(); + return(0); +} diff --git a/examples/manual/string1.lex b/examples/manual/string1.lex new file mode 100644 index 0000000..b62ed88 --- /dev/null +++ b/examples/manual/string1.lex @@ -0,0 +1,98 @@ +/* + * string1.lex: Handling strings by using input() + */ + +%{ +#include +#include + +#define ALLOC_SIZE 32 /* for (re)allocating the buffer */ + +#define isodigit(x) ((x) >= '0' && (x) <= '7') +#define hextoint(x) (isdigit((x)) ? (x) - '0' : ((x) - 'A') + 10) + +void yyerror(char *message) +{ + printf("\nError: %s\n",message); +} + +%} + +%% + +\" { + int inch,count,max_size; + char *buffer; + int temp; + + buffer = malloc(ALLOC_SIZE); + max_size = ALLOC_SIZE; + inch = input(); + count = 0; + while(inch != EOF && inch != '"' && inch != '\n'){ + if(inch == '\\'){ + inch = input(); + switch(inch){ + case '\n': inch = input(); break; + case 'b' : inch = '\b'; break; + case 't' : inch = '\t'; break; + case 'n' : inch = '\n'; break; + case 'v' : inch = '\v'; break; + case 'f' : inch = '\f'; break; + case 'r' : inch = '\r'; break; + case 'X' : + case 'x' : inch = input(); + if(isxdigit(inch)){ + temp = hextoint(toupper(inch)); + inch = input(); + if(isxdigit(inch)){ + temp = (temp << 4) + hextoint(toupper(inch)); + } else { + unput(inch); + } + inch = temp; + } else { + unput(inch); + inch = 'x'; + } + break; + default: + if(isodigit(inch)){ + temp = inch - '0'; + inch = input(); + if(isodigit(inch)){ + temp = (temp << 3) + (inch - '0'); + } else { + unput(inch); + goto done; + } + inch = input(); + if(isodigit(inch)){ + temp = (temp << 3) + (inch - '0'); + } else { + unput(inch); + } + done: + inch = temp; + } + } + } + buffer[count++] = inch; + if(count >= max_size){ + buffer = realloc(buffer,max_size + ALLOC_SIZE); + max_size += ALLOC_SIZE; + } + inch = input(); + } + if(inch == EOF || inch == '\n'){ + yyerror("Unterminated string."); + } + buffer[count] = '\0'; + printf("String = \"%s\"\n",buffer); + free(buffer); + } +. +\n +%% + + diff --git a/examples/manual/string2.lex b/examples/manual/string2.lex new file mode 100644 index 0000000..2c9d35f --- /dev/null +++ b/examples/manual/string2.lex @@ -0,0 +1,94 @@ +/* + * string2.lex: An example of using scanning strings + * by using start states. + */ + +%{ +#include +#include + +#define isodigit(x) ((x) >= '0' && (x) <= '7') +#define hextoint(x) (isdigit((x)) ? (x) - '0' : ((x) - 'A') + 10) + +char *buffer = NULL; +int buffer_size = 0; + +void yyerror(char *message) +{ + printf("\nError: %s\n",message); +} + +%} + +%x STRING + +hex (x|X)[0-9a-fA-F]{1,2} +oct [0-7]{1,3} + +%% + +\" { + buffer = malloc(1); + buffer_size = 1; strcpy(buffer,""); + BEGIN(STRING); + } +\n { + yyerror("Unterminated string"); + free(buffer); + BEGIN(INITIAL); + } +<> { + yyerror("EOF in string"); + free(buffer); + BEGIN(INITIAL); + } +[^\\\n"] { + buffer = realloc(buffer,buffer_size+yyleng+1); + buffer_size += yyleng; + strcat(buffer,yytext); + } +\\\n /* ignore this */ +\\{hex} { + int temp =0,loop = 0; + for(loop=yyleng-2; loop>0; loop--){ + temp <<= 4; + temp += hextoint(toupper(yytext[yyleng-loop])); + } + buffer = realloc(buffer,buffer_size+1); + buffer[buffer_size-1] = temp; + buffer[buffer_size] = '\0'; + buffer_size += 1; + } +\\{oct} { + int temp =0,loop = 0; + for(loop=yyleng-1; loop>0; loop--){ + temp <<= 3; + temp += (yytext[yyleng-loop] - '0'); + } + buffer = realloc(buffer,buffer_size+1); + buffer[buffer_size-1] = temp; + buffer[buffer_size] = '\0'; + buffer_size += 1; + } +\\[^\n] { + buffer = realloc(buffer,buffer_size+1); + switch(yytext[yyleng-1]){ + case 'b' : buffer[buffer_size-1] = '\b'; break; + case 't' : buffer[buffer_size-1] = '\t'; break; + case 'n' : buffer[buffer_size-1] = '\n'; break; + case 'v' : buffer[buffer_size-1] = '\v'; break; + case 'f' : buffer[buffer_size-1] = '\f'; break; + case 'r' : buffer[buffer_size-1] = '\r'; break; + default : buffer[buffer_size-1] = yytext[yyleng-1]; + } + buffer[buffer_size] = '\0'; + buffer_size += 1; + } +\" { + printf("string = \"%s\"",buffer); + free(buffer); + BEGIN(INITIAL); + } +%% + + diff --git a/examples/manual/strtest.dat b/examples/manual/strtest.dat new file mode 100644 index 0000000..28a0681 --- /dev/null +++ b/examples/manual/strtest.dat @@ -0,0 +1,21 @@ +"This is a string" +"The next string will be empty" +"" +"This is a string with a \b(\\b) in it" +"This is a string with a \t(\\t) in it" +"This is a string with a \n(\\n) in it" +"This is a string with a \v(\\v) in it" +"This is a string with a \f(\\f) in it" +"This is a string with a \r(\\r) in it" +"This is a string with a \"(\\\") in it" +"This is a string with a \z(\\z) in it" +"This is a string with a \X4a(\\X4a) in it" +"This is a string with a \x4a(\\x4a) in it" +"This is a string with a \x7(\\x7) in it" +"This is a string with a \112(\\112) in it" +"This is a string with a \043(\\043) in it" +"This is a string with a \7(\\7) in it" +"This is a multi-line \ +string" +"This is an unterminated string +"This is an unterminated string too diff --git a/examples/manual/unput.lex b/examples/manual/unput.lex new file mode 100644 index 0000000..161471a --- /dev/null +++ b/examples/manual/unput.lex @@ -0,0 +1,32 @@ +/* + * unput.l : An example of what *not* + * to do with unput(). + */ + + +%{ +#include + +void putback_yytext(void); +%} + +%% +foobar putback_yytext(); +raboof putback_yytext(); +%% + +void putback_yytext(void) +{ + int i; + int l = strlen(yytext); + char buffer[YY_BUF_SIZE]; + + strcpy(buffer,yytext); + printf("Got: %s\n",yytext); + for(i=0; i + +void user_action(void); + +#define YY_USER_ACTION user_action(); + +%} + +%% + +.* ECHO; +\n ECHO; + +%% + +void user_action(void) +{ + int loop; + + for(loop=0; loop + +void yyerror(char *message) +{ + printf("Error: %s\n",message); +} + +%} + +%x STRING + +%% +\" BEGIN(STRING); + +[^\\\n"]* yymore(); +<> yyerror("EOF in string."); BEGIN(INITIAL); +\n yyerror("Unterminated string."); BEGIN(INITIAL); +\\\n yymore(); +\" { + yytext[yyleng-1] = '\0'; + printf("string = \"%s\"",yytext); BEGIN(INITIAL); + } +%% diff --git a/examples/manual/yymore2.lex b/examples/manual/yymore2.lex new file mode 100644 index 0000000..f49ea23 --- /dev/null +++ b/examples/manual/yymore2.lex @@ -0,0 +1,33 @@ +/* + * yymore.lex: An example of using yymore() + * to good effect. + */ + +%{ +#include + +void yyerror(char *message) +{ + printf("Error: %s\n",message); +} + +%} + +%x STRING + +%% +\" BEGIN(STRING); + +[^\\\n"]* yymore(); +<> yyerror("EOF in string."); BEGIN(INITIAL); +\n yyerror("Unterminated string."); BEGIN(INITIAL); +\\\n { + bcopy(yytext,yytext+2,yyleng-2); + yytext += 2; yyleng -= 2; + yymore(); + } +\" { + yyleng -= 1; yytext[yyleng] = '\0'; + printf("string = \"%s\"",yytext); BEGIN(INITIAL); + } +%% diff --git a/examples/manual/yymoretest.dat b/examples/manual/yymoretest.dat new file mode 100644 index 0000000..614c3c4 --- /dev/null +++ b/examples/manual/yymoretest.dat @@ -0,0 +1,7 @@ +"This is a test \ +of multi-line string \ +scanning in flex. \ +This may be breaking some law \ +of usage though..." + + diff --git a/examples/testxxLexer.l b/examples/testxxLexer.l new file mode 100644 index 0000000..9421541 --- /dev/null +++ b/examples/testxxLexer.l @@ -0,0 +1,58 @@ + // An example of using the flex C++ scanner class. + +%option C++ noyywrap + +%{ +int mylineno = 0; +%} + +string \"[^\n"]+\" + +ws [ \t]+ + +alpha [A-Za-z] +dig [0-9] +name ({alpha}|{dig}|\$)({alpha}|{dig}|\_|\.|\-|\/|\$)* +num1 [-+]?{dig}+\.?([eE][-+]?{dig}+)? +num2 [-+]?{dig}*\.{dig}+([eE][-+]?{dig}+)? +number {num1}|{num2} + +%% + +{ws} /* skip blanks and tabs */ + +"/*" { + int c; + + while((c = yyinput()) != 0) + { + if(c == '\n') + ++mylineno; + + else if(c == '*') + { + if((c = yyinput()) == '/') + break; + else + unput(c); + } + } + } + +{number} cout << "number " << YYText() << '\n'; + +\n mylineno++; + +{name} cout << "name " << YYText() << '\n'; + +{string} cout << "string " << YYText() << '\n'; + +%% + +int main( int /* argc */, char** /* argv */ ) + { + FlexLexer* lexer = new yyFlexLexer; + while(lexer->yylex() != 0) + ; + return 0; + } -- cgit v1.2.3 From 5fd717cd0c50e392c39623824d412a6548d5c836 Mon Sep 17 00:00:00 2001 From: Will Estes Date: Tue, 24 Jul 2001 20:23:36 +0000 Subject: re-add these files --- examples/fastwc/README | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ examples/fastwc/mywc.c | 26 +++++++++++++++++++++++ examples/fastwc/wc1.l | 18 ++++++++++++++++ examples/fastwc/wc2.l | 20 ++++++++++++++++++ examples/fastwc/wc3.l | 24 ++++++++++++++++++++++ examples/fastwc/wc4.l | 27 ++++++++++++++++++++++++ examples/fastwc/wc5.l | 24 ++++++++++++++++++++++ 7 files changed, 195 insertions(+) create mode 100644 examples/fastwc/README create mode 100644 examples/fastwc/mywc.c create mode 100644 examples/fastwc/wc1.l create mode 100644 examples/fastwc/wc2.l create mode 100644 examples/fastwc/wc3.l create mode 100644 examples/fastwc/wc4.l create mode 100644 examples/fastwc/wc5.l (limited to 'examples') diff --git a/examples/fastwc/README b/examples/fastwc/README new file mode 100644 index 0000000..0dd3afe --- /dev/null +++ b/examples/fastwc/README @@ -0,0 +1,56 @@ +This directory contains some examples illustrating techniques for extracting +high-performance from flex scanners. Each program implements a simplified +version of the Unix "wc" tool: read text from stdin and print the number of +characters, words, and lines present in the text. All programs were compiled +using gcc (version unavailable, sorry) with the -O flag, and run on a +SPARCstation 1+. The input used was a PostScript file, mainly containing +figures, with the following "wc" counts: + + lines words characters + 214217 635954 2592172 + + +The basic principles illustrated by these programs are: + + - match as much text with each rule as possible + - adding rules does not slow you down! + - avoid backing up + +and the big caveat that comes with them is: + + - you buy performance with decreased maintainability; make + sure you really need it before applying the above techniques. + +See the "Performance Considerations" section of flexdoc for more +details regarding these principles. + + +The different versions of "wc": + + mywc.c + a simple but fairly efficient C version + + wc1.l a naive flex "wc" implementation + + wc2.l somewhat faster; adds rules to match multiple tokens at once + + wc3.l faster still; adds more rules to match longer runs of tokens + + wc4.l fastest; still more rules added; hard to do much better + using flex (or, I suspect, hand-coding) + + wc5.l identical to wc3.l except one rule has been slightly + shortened, introducing backing-up + +Timing results (all times in user CPU seconds): + + program time notes + ------- ---- ----- + wc1 16.4 default flex table compression (= -Cem) + wc1 6.7 -Cf compression option + /bin/wc 5.8 Sun's standard "wc" tool + mywc 4.6 simple but better C implementation! + wc2 4.6 as good as C implementation; built using -Cf + wc3 3.8 -Cf + wc4 3.3 -Cf + wc5 5.7 -Cf; ouch, backing up is expensive diff --git a/examples/fastwc/mywc.c b/examples/fastwc/mywc.c new file mode 100644 index 0000000..92e5a36 --- /dev/null +++ b/examples/fastwc/mywc.c @@ -0,0 +1,26 @@ +/* A simple but fairly efficient C version of the Unix "wc" tool */ + +#include +#include + +main() +{ + register int c, cc = 0, wc = 0, lc = 0; + FILE *f = stdin; + + while ((c = getc(f)) != EOF) { + ++cc; + if (isgraph(c)) { + ++wc; + do { + c = getc(f); + if (c == EOF) + goto done; + ++cc; + } while (isgraph(c)); + } + if (c == '\n') + ++lc; + } +done: printf( "%8d%8d%8d\n", lc, wc, cc ); +} diff --git a/examples/fastwc/wc1.l b/examples/fastwc/wc1.l new file mode 100644 index 0000000..d6696bc --- /dev/null +++ b/examples/fastwc/wc1.l @@ -0,0 +1,18 @@ +/* First cut at a flex-based "wc" tool. */ + +ws [ \t] +nonws [^ \t\n] + +%% + int cc = 0, wc = 0, lc = 0; + +{nonws}+ cc += yyleng; ++wc; + +{ws}+ cc += yyleng; + +\n ++lc; ++cc; + +<> { + printf( "%8d %8d %8d\n", lc, wc, cc ); + yyterminate(); + } diff --git a/examples/fastwc/wc2.l b/examples/fastwc/wc2.l new file mode 100644 index 0000000..bd63cd4 --- /dev/null +++ b/examples/fastwc/wc2.l @@ -0,0 +1,20 @@ +/* Somewhat faster "wc" tool: match more text with each rule */ + +ws [ \t] +nonws [^ \t\n] +word {ws}*{nonws}+ + +%% + int cc = 0, wc = 0, lc = 0; + +{word}{ws}* cc += yyleng; ++wc; +{word}{ws}*\n cc += yyleng; ++wc; ++lc; + +{ws}+ cc += yyleng; + +\n+ cc += yyleng; lc += yyleng; + +<> { + printf( "%8d %8d %8d\n", lc, wc, cc ); + yyterminate(); + } diff --git a/examples/fastwc/wc3.l b/examples/fastwc/wc3.l new file mode 100644 index 0000000..7c5f2e2 --- /dev/null +++ b/examples/fastwc/wc3.l @@ -0,0 +1,24 @@ +/* Somewhat faster still: potentially match a lot of text with each rule */ + +ws [ \t] +nonws [^ \t\n] +word {ws}*{nonws}+ +words {word}{ws}+ + +%% + int cc = 0, wc = 0, lc = 0; + +{word}{ws}* cc += yyleng; ++wc; +{word}{ws}*\n cc += yyleng; ++wc; ++lc; +{words}{word}{ws}* cc += yyleng; wc += 2; +{words}{2}{word}{ws}* cc += yyleng; wc += 3; +{words}{3}{word}{ws}* cc += yyleng; wc += 4; + +{ws}+ cc += yyleng; + +\n+ cc += yyleng; lc += yyleng; + +<> { + printf( "%8d %8d %8d\n", lc, wc, cc ); + yyterminate(); + } diff --git a/examples/fastwc/wc4.l b/examples/fastwc/wc4.l new file mode 100644 index 0000000..cbe56f6 --- /dev/null +++ b/examples/fastwc/wc4.l @@ -0,0 +1,27 @@ +/* Fastest version of wc: add rules to pick up newlines, too */ + +ws [ \t] +nonws [^ \t\n] +word {ws}*{nonws}+ +words {word}{ws}+ + +%% + int cc = 0, wc = 0, lc = 0; + +{word}{ws}* ++wc; cc += yyleng; +{word}{ws}*\n ++wc; cc += yyleng; ++lc; +{words}{word}{ws}* wc += 2; cc += yyleng; +{words}{word}{ws}*\n wc += 2; cc += yyleng; ++lc; +{words}{2}{word}{ws}* wc += 3; cc += yyleng; +{words}{2}{word}{ws}*\n wc += 3; cc += yyleng; ++lc; +{words}{3}{word}{ws}* wc += 4; cc += yyleng; +{words}{3}{word}{ws}*\n wc += 4; cc += yyleng; ++lc; + +{ws}+ cc += yyleng; + +\n+ cc += yyleng; lc += yyleng; + +<> { + printf( "%8d %8d %8d\n", lc, wc, cc ); + yyterminate(); + } diff --git a/examples/fastwc/wc5.l b/examples/fastwc/wc5.l new file mode 100644 index 0000000..8fe17b6 --- /dev/null +++ b/examples/fastwc/wc5.l @@ -0,0 +1,24 @@ +/* Oops; slight change from wc3.l introduces backtracking */ + +ws [ \t] +nonws [^ \t\n] +word {ws}*{nonws}+ +words {word}{ws}+ + +%% + int cc = 0, wc = 0, lc = 0; + +{word}{ws}* cc += yyleng; ++wc; +{word}{ws}*\n cc += yyleng; ++wc; ++lc; +{words}{word} cc += yyleng; wc += 2; /* oops */ +{words}{2}{word}{ws}* cc += yyleng; wc += 3; +{words}{3}{word}{ws}* cc += yyleng; wc += 4; + +{ws}+ cc += yyleng; + +\n+ cc += yyleng; lc += yyleng; + +<> { + printf( "%8d %8d %8d\n", lc, wc, cc ); + yyterminate(); + } -- cgit v1.2.3 From 75a2fd64ccaca871257fd678ee0be9b39b6abd1d Mon Sep 17 00:00:00 2001 From: Will Estes Date: Wed, 19 Sep 2001 19:19:03 +0000 Subject: made preliminary c++ fixes; the intent is to make it work with recent c++ compilers --- examples/testxxLexer.l | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/testxxLexer.l b/examples/testxxLexer.l index 9421541..e2aed33 100644 --- a/examples/testxxLexer.l +++ b/examples/testxxLexer.l @@ -39,13 +39,13 @@ number {num1}|{num2} } } -{number} cout << "number " << YYText() << '\n'; +{number} FLEX_STD cout << "number " << YYText() << '\n'; \n mylineno++; -{name} cout << "name " << YYText() << '\n'; +{name} FLEX_STD cout << "name " << YYText() << '\n'; -{string} cout << "string " << YYText() << '\n'; +{string} FLEX_STD cout << "string " << YYText() << '\n'; %% -- cgit v1.2.3 From 9a4081f734e67bdcf44d378eea6f8f90b4978ecf Mon Sep 17 00:00:00 2001 From: Will Estes Date: Wed, 19 Sep 2001 19:37:43 +0000 Subject: commit the backwash from the branch merges --- examples/fastwc/wc1.l | 1 + examples/fastwc/wc2.l | 1 + examples/fastwc/wc3.l | 1 + examples/fastwc/wc4.l | 1 + examples/fastwc/wc5.l | 1 + 5 files changed, 5 insertions(+) (limited to 'examples') diff --git a/examples/fastwc/wc1.l b/examples/fastwc/wc1.l index d6696bc..0d4fcf2 100644 --- a/examples/fastwc/wc1.l +++ b/examples/fastwc/wc1.l @@ -3,6 +3,7 @@ ws [ \t] nonws [^ \t\n] +%option main noyywrap %% int cc = 0, wc = 0, lc = 0; diff --git a/examples/fastwc/wc2.l b/examples/fastwc/wc2.l index bd63cd4..0da9953 100644 --- a/examples/fastwc/wc2.l +++ b/examples/fastwc/wc2.l @@ -4,6 +4,7 @@ ws [ \t] nonws [^ \t\n] word {ws}*{nonws}+ +%option main noyywrap %% int cc = 0, wc = 0, lc = 0; diff --git a/examples/fastwc/wc3.l b/examples/fastwc/wc3.l index 7c5f2e2..3cc5d57 100644 --- a/examples/fastwc/wc3.l +++ b/examples/fastwc/wc3.l @@ -5,6 +5,7 @@ nonws [^ \t\n] word {ws}*{nonws}+ words {word}{ws}+ +%option main noyywrap %% int cc = 0, wc = 0, lc = 0; diff --git a/examples/fastwc/wc4.l b/examples/fastwc/wc4.l index cbe56f6..90c36ee 100644 --- a/examples/fastwc/wc4.l +++ b/examples/fastwc/wc4.l @@ -5,6 +5,7 @@ nonws [^ \t\n] word {ws}*{nonws}+ words {word}{ws}+ +%option main noyywrap %% int cc = 0, wc = 0, lc = 0; diff --git a/examples/fastwc/wc5.l b/examples/fastwc/wc5.l index 8fe17b6..c479480 100644 --- a/examples/fastwc/wc5.l +++ b/examples/fastwc/wc5.l @@ -5,6 +5,7 @@ nonws [^ \t\n] word {ws}*{nonws}+ words {word}{ws}+ +%option main noyywrap %% int cc = 0, wc = 0, lc = 0; -- cgit v1.2.3 From de8ca40a46cdb20c5f46b1901c7977d800d268d3 Mon Sep 17 00:00:00 2001 From: Will Estes Date: Tue, 5 Mar 2002 14:45:39 +0000 Subject: renamed Makefile to Makefile.examples for automake's sake --- examples/manual/Makefile | 88 ------------------------------------------------ 1 file changed, 88 deletions(-) delete mode 100644 examples/manual/Makefile (limited to 'examples') diff --git a/examples/manual/Makefile b/examples/manual/Makefile deleted file mode 100644 index f4d8297..0000000 --- a/examples/manual/Makefile +++ /dev/null @@ -1,88 +0,0 @@ -############################################################# -# -# Makefile : Makefile for Flex examples. -# Author : G.T.Nicol -# Last Updated : 1993/10/05 -# -# If you use bison, you may have to supply an alloca -# -############################################################# - -CC = gcc -g -LEX = flex -i -I -YACC = bison -d -y -ALLOCA = - -############################################################ -# -# DO NOT CHANGE ANYTHING FROM HERE ON !!!!!!!!! -# -############################################################ - -all: expr front myname eof wc replace user_act string1\ - string2 yymore numbers dates cat - -expr: expr.y expr.lex - $(YACC) expr.y - $(LEX) expr.lex - $(CC) -o expr lex.yy.c y.tab.c $(ALLOCA) -ll -lm - -front: front.y front.lex - $(YACC) front.y - $(LEX) front.lex - $(CC) -o front lex.yy.c y.tab.c $(ALLOCA) -ll -lm - -numbers: numbers.lex - $(LEX) numbers.lex - $(CC) lex.yy.c -o numbers - -dates: dates.lex - $(LEX) dates.lex - $(CC) lex.yy.c -o dates -ll - -yymore: yymore.lex - $(LEX) yymore.lex - $(CC) lex.yy.c -o yymore -ll - -string1: string1.lex - $(LEX) string1.lex - $(CC) lex.yy.c -o string1 -ll - -string2: string2.lex - $(LEX) string2.lex - $(CC) lex.yy.c -o string2 -ll - -myname: myname.lex - $(LEX) myname.lex - $(CC) lex.yy.c -o myname -ll - -myname2: myname2.lex - $(LEX) myname2.lex - $(CC) lex.yy.c -o myname2 -ll - -eof: eof_rules.lex - $(LEX) eof_rules.lex - $(CC) lex.yy.c -o eof -ll - -wc: wc.lex - $(LEX) wc.lex - $(CC) lex.yy.c -o wc -ll - -cat: cat.lex - $(LEX) cat.lex - $(CC) lex.yy.c -o cat -ll - -replace: replace.lex - $(LEX) replace.lex - $(CC) lex.yy.c -o replace -ll - -user_act: expr.y expr.lex - $(LEX) user_act.lex - $(CC) -o user_act lex.yy.c -ll - -clean: - rm -f *.BAK *.o core *~* *.a - rm -f *.tab.h *.tab.c - rm -f myname expr lex.yy.c *.out eof wc yymore - rm -f replace front user_act string1 string2 - rm -f dates numbers cat -- cgit v1.2.3 From b9c026a2c004fc8ae735c4735adcdd04e25b0798 Mon Sep 17 00:00:00 2001 From: Will Estes Date: Tue, 5 Mar 2002 14:47:36 +0000 Subject: examples/manual directory now fits into automake --- examples/manual/.cvsignore | 2 + examples/manual/Makefile.am | 55 ++++++++++++++++++++++++ examples/manual/Makefile.examples | 88 +++++++++++++++++++++++++++++++++++++++ examples/manual/README | 17 +++----- 4 files changed, 151 insertions(+), 11 deletions(-) create mode 100644 examples/manual/.cvsignore create mode 100644 examples/manual/Makefile.am create mode 100644 examples/manual/Makefile.examples (limited to 'examples') diff --git a/examples/manual/.cvsignore b/examples/manual/.cvsignore new file mode 100644 index 0000000..282522d --- /dev/null +++ b/examples/manual/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/examples/manual/Makefile.am b/examples/manual/Makefile.am new file mode 100644 index 0000000..9ab3004 --- /dev/null +++ b/examples/manual/Makefile.am @@ -0,0 +1,55 @@ +# This file is part of flex. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: + +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. + +# Neither the name of the University nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. + +# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE. + +EXTRA_DIST = \ + ChangeLog \ + Makefile.examples \ + README \ + cat.lex \ + dates.lex \ + datetest.dat \ + eof_rules.lex \ + eof_test01.txt \ + eof_test02.txt \ + eof_test03.txt \ + expr.lex \ + expr.y \ + front.lex \ + front.y \ + j2t.lex \ + myname.lex \ + myname.txt \ + myname2.lex \ + numbers.lex \ + pas_include.lex \ + pascal.lex \ + reject.lex \ + replace.lex \ + string1.lex \ + string2.lex \ + strtest.dat \ + unput.lex \ + user_act.lex \ + userinit.lex \ + wc.lex \ + yymore.lex \ + yymore2.lex \ + yymoretest.dat diff --git a/examples/manual/Makefile.examples b/examples/manual/Makefile.examples new file mode 100644 index 0000000..f4d8297 --- /dev/null +++ b/examples/manual/Makefile.examples @@ -0,0 +1,88 @@ +############################################################# +# +# Makefile : Makefile for Flex examples. +# Author : G.T.Nicol +# Last Updated : 1993/10/05 +# +# If you use bison, you may have to supply an alloca +# +############################################################# + +CC = gcc -g +LEX = flex -i -I +YACC = bison -d -y +ALLOCA = + +############################################################ +# +# DO NOT CHANGE ANYTHING FROM HERE ON !!!!!!!!! +# +############################################################ + +all: expr front myname eof wc replace user_act string1\ + string2 yymore numbers dates cat + +expr: expr.y expr.lex + $(YACC) expr.y + $(LEX) expr.lex + $(CC) -o expr lex.yy.c y.tab.c $(ALLOCA) -ll -lm + +front: front.y front.lex + $(YACC) front.y + $(LEX) front.lex + $(CC) -o front lex.yy.c y.tab.c $(ALLOCA) -ll -lm + +numbers: numbers.lex + $(LEX) numbers.lex + $(CC) lex.yy.c -o numbers + +dates: dates.lex + $(LEX) dates.lex + $(CC) lex.yy.c -o dates -ll + +yymore: yymore.lex + $(LEX) yymore.lex + $(CC) lex.yy.c -o yymore -ll + +string1: string1.lex + $(LEX) string1.lex + $(CC) lex.yy.c -o string1 -ll + +string2: string2.lex + $(LEX) string2.lex + $(CC) lex.yy.c -o string2 -ll + +myname: myname.lex + $(LEX) myname.lex + $(CC) lex.yy.c -o myname -ll + +myname2: myname2.lex + $(LEX) myname2.lex + $(CC) lex.yy.c -o myname2 -ll + +eof: eof_rules.lex + $(LEX) eof_rules.lex + $(CC) lex.yy.c -o eof -ll + +wc: wc.lex + $(LEX) wc.lex + $(CC) lex.yy.c -o wc -ll + +cat: cat.lex + $(LEX) cat.lex + $(CC) lex.yy.c -o cat -ll + +replace: replace.lex + $(LEX) replace.lex + $(CC) lex.yy.c -o replace -ll + +user_act: expr.y expr.lex + $(LEX) user_act.lex + $(CC) -o user_act lex.yy.c -ll + +clean: + rm -f *.BAK *.o core *~* *.a + rm -f *.tab.h *.tab.c + rm -f myname expr lex.yy.c *.out eof wc yymore + rm -f replace front user_act string1 string2 + rm -f dates numbers cat diff --git a/examples/manual/README b/examples/manual/README index 860f300..e11569a 100644 --- a/examples/manual/README +++ b/examples/manual/README @@ -1,17 +1,12 @@ -This directory contains the example programs from the manual, and a few -other things as well. To make all the programs, simply type "make", -and assuming you have flex and gcc, all will be well. +This directory contains the example programs from the manual, and a +few other things as well. To make all the programs, simply type "make +-f Makefile.examples", and assuming you have flex and gcc, all will be +well. To build the programs individually, type - make program_name + make -f Makefile.examples program_name For example: - make expr - - -The subdirectory FILTER contains a collection of the silly filters -that have appeared on the Internet over the years. The author of the -flex manual has included them for fun, but does not guarantee they will -work with flex, or even work at all. + make -f Makefile.examples expr -- cgit v1.2.3 From 9e910d86a3ce501e3833c74902d55725f461257e Mon Sep 17 00:00:00 2001 From: Will Estes Date: Tue, 5 Mar 2002 14:48:37 +0000 Subject: examples/fastwc now fits into automake --- examples/fastwc/.cvsignore | 2 ++ examples/fastwc/Makefile.am | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 examples/fastwc/.cvsignore create mode 100644 examples/fastwc/Makefile.am (limited to 'examples') diff --git a/examples/fastwc/.cvsignore b/examples/fastwc/.cvsignore new file mode 100644 index 0000000..3dda729 --- /dev/null +++ b/examples/fastwc/.cvsignore @@ -0,0 +1,2 @@ +Makefile.in +Makefile diff --git a/examples/fastwc/Makefile.am b/examples/fastwc/Makefile.am new file mode 100644 index 0000000..b2831d9 --- /dev/null +++ b/examples/fastwc/Makefile.am @@ -0,0 +1,29 @@ +# This file is part of flex. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: + +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. + +# Neither the name of the University nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. + +# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE. + +EXTRA_DIST = \ + wc5.l \ + wc4.l \ + wc3.l \ + wc2.l \ + wc1.l \ + mywc.c \ + README -- cgit v1.2.3 From 6ea94e7c8675fecaf618abd612cab2bdc1baefd3 Mon Sep 17 00:00:00 2001 From: Will Estes Date: Tue, 5 Mar 2002 14:49:29 +0000 Subject: now examples/ fits into automake --- examples/.cvsignore | 2 ++ examples/Makefile.am | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 examples/.cvsignore create mode 100644 examples/Makefile.am (limited to 'examples') diff --git a/examples/.cvsignore b/examples/.cvsignore new file mode 100644 index 0000000..3dda729 --- /dev/null +++ b/examples/.cvsignore @@ -0,0 +1,2 @@ +Makefile.in +Makefile diff --git a/examples/Makefile.am b/examples/Makefile.am new file mode 100644 index 0000000..62688ba --- /dev/null +++ b/examples/Makefile.am @@ -0,0 +1,29 @@ +# This file is part of flex. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: + +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. + +# Neither the name of the University nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. + +# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE. + +EXTRA_DIST = \ + testxxLexer.l \ + debflex.awk \ + README + +SUBDIRS = \ + manual \ + fastwc -- cgit v1.2.3 From 0bef977b956d83350ef44f5b2240dde86537eb51 Mon Sep 17 00:00:00 2001 From: Will Estes Date: Mon, 23 Jul 2012 05:37:37 -0400 Subject: remove unneeded .cvsignore files --- examples/.cvsignore | 2 -- examples/fastwc/.cvsignore | 2 -- examples/manual/.cvsignore | 2 -- 3 files changed, 6 deletions(-) delete mode 100644 examples/.cvsignore delete mode 100644 examples/fastwc/.cvsignore delete mode 100644 examples/manual/.cvsignore (limited to 'examples') diff --git a/examples/.cvsignore b/examples/.cvsignore deleted file mode 100644 index 3dda729..0000000 --- a/examples/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile.in -Makefile diff --git a/examples/fastwc/.cvsignore b/examples/fastwc/.cvsignore deleted file mode 100644 index 3dda729..0000000 --- a/examples/fastwc/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile.in -Makefile diff --git a/examples/manual/.cvsignore b/examples/manual/.cvsignore deleted file mode 100644 index 282522d..0000000 --- a/examples/manual/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Makefile.in -- cgit v1.2.3 From 8091dc907663673d9e0295c57fa446bdd38e9fab Mon Sep 17 00:00:00 2001 From: Yuri Date: Thu, 17 Jul 2014 14:07:30 -0700 Subject: Removed deprecated 'register' storage class specifier. clang-3.5.0 now complains about them: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register] --- examples/fastwc/mywc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/fastwc/mywc.c b/examples/fastwc/mywc.c index 92e5a36..b07d5f0 100644 --- a/examples/fastwc/mywc.c +++ b/examples/fastwc/mywc.c @@ -5,7 +5,7 @@ main() { - register int c, cc = 0, wc = 0, lc = 0; + int c, cc = 0, wc = 0, lc = 0; FILE *f = stdin; while ((c = getc(f)) != EOF) { -- cgit v1.2.3