|
Packit |
f00812 |
/*
|
|
Packit |
f00812 |
* This file is part of flex.
|
|
Packit |
f00812 |
*
|
|
Packit |
f00812 |
* Redistribution and use in source and binary forms, with or without
|
|
Packit |
f00812 |
* modification, are permitted provided that the following conditions
|
|
Packit |
f00812 |
* are met:
|
|
Packit |
f00812 |
*
|
|
Packit |
f00812 |
* 1. Redistributions of source code must retain the above copyright
|
|
Packit |
f00812 |
* notice, this list of conditions and the following disclaimer.
|
|
Packit |
f00812 |
* 2. Redistributions in binary form must reproduce the above copyright
|
|
Packit |
f00812 |
* notice, this list of conditions and the following disclaimer in the
|
|
Packit |
f00812 |
* documentation and/or other materials provided with the distribution.
|
|
Packit |
f00812 |
*
|
|
Packit |
f00812 |
* Neither the name of the University nor the names of its contributors
|
|
Packit |
f00812 |
* may be used to endorse or promote products derived from this software
|
|
Packit |
f00812 |
* without specific prior written permission.
|
|
Packit |
f00812 |
*
|
|
Packit |
f00812 |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
|
Packit |
f00812 |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
Packit |
f00812 |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
Packit |
f00812 |
* PURPOSE.
|
|
Packit |
f00812 |
*/
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
%{
|
|
Packit |
f00812 |
/* A template scanner file to build "scanner.c". */
|
|
Packit |
f00812 |
#include <stdio.h>
|
|
Packit |
f00812 |
#include <stdlib.h>
|
|
Packit |
f00812 |
#include "config.h"
|
|
Packit |
f00812 |
/*#include "parser.h" */
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
#define err_abort() do{printf("ERROR: flex line %d. input line %d.\n", __LINE__, yylineno); abort();} while(0)
|
|
Packit |
f00812 |
#define a_ok() do{printf("OK: flex line %d. input line %d.\n", __LINE__, yylineno); return 1;}while(0)
|
|
Packit |
f00812 |
%}
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
%option 8bit prefix="test"
|
|
Packit |
f00812 |
%option nounput nomain noyywrap noinput
|
|
Packit |
f00812 |
%option warn
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
%%
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
^"^alpha:"[[:^alpha:]]+@alpha@\n printf("OK: %s", yytext); ++yylineno; return 1;
|
|
Packit |
f00812 |
^"^digit:"[[:^digit:]]+@digit@\n printf("OK: %s", yytext); ++yylineno; return 1;
|
|
Packit |
f00812 |
^"^alnum:"[[:^alnum:]]+@alnum@\n printf("OK: %s", yytext); ++yylineno; return 1;
|
|
Packit |
f00812 |
^"^upper:"[[:^upper:]]+@upper@\n printf("OK: %s", yytext); ++yylineno; return 1;
|
|
Packit |
f00812 |
^"^lower:"[[:^lower:]]+@lower@\n printf("OK: %s", yytext); ++yylineno; return 1;
|
|
Packit |
f00812 |
^"^space:"[[:^space:]]+@space@\n printf("OK: %s", yytext); ++yylineno; return 1;
|
|
Packit |
f00812 |
^"^blank:"[[:^blank:]]+@blank@\n printf("OK: %s", yytext); ++yylineno; return 1;
|
|
Packit |
f00812 |
^"^punct:"[[:^punct:]]+@punct@\n printf("OK: %s", yytext); ++yylineno; return 1;
|
|
Packit |
f00812 |
^"^cntrl:"[[:^cntrl:]]+@cntrl@\n printf("OK: %s", yytext); ++yylineno; return 1;
|
|
Packit |
f00812 |
^"^xdigit:"[[:^xdigit:]]+@xdigit@\n printf("OK: %s", yytext); ++yylineno; return 1;
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
^"a-d:"[[:alpha:]]{-}[[:digit:]]+@a-d@\n printf("OK: %s", yytext); ++yylineno; return 1;
|
|
Packit |
f00812 |
^"l-xyz:"([[:lower:]]{-}[xyz])+@l-xyz@\n printf("OK: %s", yytext); ++yylineno; return 1;
|
|
Packit |
f00812 |
^"abcd-bc:"([abcd]{-}[bc])+@abcd-bc@\n printf("OK: %s", yytext); ++yylineno; return 1;
|
|
Packit |
f00812 |
^"abcde-b-c:"([abcde]{-}[b]{-}[c])+@abcde-b-c@\n printf("OK: %s", yytext); ++yylineno; return 1;
|
|
Packit |
f00812 |
^"^XY-^XYZ:"([^XY]{-}[^XYZ])+@^XY-^XYZ@\n printf("OK: %s", yytext); ++yylineno; return 1;
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
^"a+d:"([[:alpha:]]{+}[[:digit:]])+"@a+d@"\n a_ok();
|
|
Packit |
f00812 |
^"a-u+Q:"([[:alpha:]]{-}[[:upper:]]{+}[Q])+"@a-u+Q@"\n a_ok();
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
^"ia:"(?i:a)+@ia@\n printf("OK: %s", yytext); ++yylineno; return 1;
|
|
Packit |
f00812 |
^"iabc:"(?i:abc)+@iabc@\n printf("OK: %s", yytext); ++yylineno; return 1;
|
|
Packit |
f00812 |
^"ia-c:"(?i:[a-c]+)@ia-c@\n printf("OK: %s", yytext); ++yylineno; return 1;
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
/* We don't want this one to match. */
|
|
Packit |
f00812 |
^"check-a:"(?i:(?-i:A))@\n err_abort();
|
|
Packit |
f00812 |
^"check-a:"(?i:(?-i:(?i:A)))@\n printf("OK: %s", yytext); ++yylineno; return 1;
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
/* We don't want this one to match. */
|
|
Packit |
f00812 |
^"dot-all-1:"(?-s:XXX.*)@dot-all-1@\n err_abort();
|
|
Packit |
f00812 |
^"dot-all-1:"(?s:XXX.*)@dot-all-1@\n a_ok();
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
^"x1:"(?x: a | b )+@x1@\n a_ok();
|
|
Packit |
f00812 |
^"x2:"(?x: a |
|
|
Packit |
f00812 |
(?# Comment )
|
|
Packit |
f00812 |
b
|
|
Packit |
f00812 |
)+@x2@\n a_ok();
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
.|\n { err_abort(); }
|
|
Packit |
f00812 |
%%
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
int main(void);
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
int
|
|
Packit |
f00812 |
main ()
|
|
Packit |
f00812 |
{
|
|
Packit |
f00812 |
yyin = stdin;
|
|
Packit |
f00812 |
yyout = stdout;
|
|
Packit |
f00812 |
while (yylex())
|
|
Packit |
f00812 |
;
|
|
Packit |
f00812 |
printf("TEST RETURNING OK.\n");
|
|
Packit |
f00812 |
return 0;
|
|
Packit |
f00812 |
}
|