|
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 |
/* A reentrant scanner.
|
|
Packit |
f00812 |
This file will not compile under flex version <= 2.5.4.
|
|
Packit |
f00812 |
Sample Input:
|
|
Packit |
f00812 |
# this is a comment
|
|
Packit |
f00812 |
foo = true
|
|
Packit |
f00812 |
bar = "string value"
|
|
Packit |
f00812 |
integer = 43
|
|
Packit |
f00812 |
*/
|
|
Packit |
f00812 |
%{
|
|
Packit |
f00812 |
#include "config.h"
|
|
Packit |
f00812 |
%}
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
%option prefix="test"
|
|
Packit |
f00812 |
%option nounput noyywrap noyylineno warn nodefault noinput
|
|
Packit |
f00812 |
%option reentrant
|
|
Packit |
f00812 |
%option noansi-definitions noansi-prototypes
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
IDENT [[:alnum:]_-]
|
|
Packit |
f00812 |
WS [[:blank:]]
|
|
Packit |
f00812 |
%%
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
^{IDENT}+{WS}*={WS}*(true|false){WS}*\r?\n { return 100;}
|
|
Packit |
f00812 |
^{IDENT}+{WS}*={WS}*\"[^\"\n\r]*\"{WS}*\r?\n { return 101;}
|
|
Packit |
f00812 |
^{IDENT}+{WS}*={WS}*[[:digit:]]+{WS}*\r?\n { return 102;}
|
|
Packit |
f00812 |
^{WS}*#.*\r?\n { }
|
|
Packit |
f00812 |
^{WS}*\r?\n { }
|
|
Packit |
f00812 |
.|\n { fprintf(stderr,"Invalid line.\n"); exit(-1);}
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
%%
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
int main(void);
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
int main ()
|
|
Packit |
f00812 |
{
|
|
Packit |
f00812 |
yyscan_t lexer;
|
|
Packit |
f00812 |
yylex_init( &lexer );
|
|
Packit |
f00812 |
yyset_out ( stdout,lexer);
|
|
Packit |
f00812 |
yyset_in ( stdin, lexer);
|
|
Packit |
f00812 |
while( yylex(lexer) )
|
|
Packit |
f00812 |
{
|
|
Packit |
f00812 |
}
|
|
Packit |
f00812 |
yylex_destroy( lexer );
|
|
Packit |
f00812 |
printf("TEST RETURNING OK.\n");
|
|
Packit |
f00812 |
return 0;
|
|
Packit |
f00812 |
}
|
|
Packit |
f00812 |
|