xref: /netbsd-src/external/bsd/flex/dist/tests/basic_r.l (revision 56bd85463476f90bb489799c99292bb30d6771c0)
130da1778Schristos /*
230da1778Schristos  * This file is part of flex.
330da1778Schristos  *
430da1778Schristos  * Redistribution and use in source and binary forms, with or without
530da1778Schristos  * modification, are permitted provided that the following conditions
630da1778Schristos  * are met:
730da1778Schristos  *
830da1778Schristos  * 1. Redistributions of source code must retain the above copyright
930da1778Schristos  *    notice, this list of conditions and the following disclaimer.
1030da1778Schristos  * 2. Redistributions in binary form must reproduce the above copyright
1130da1778Schristos  *    notice, this list of conditions and the following disclaimer in the
1230da1778Schristos  *    documentation and/or other materials provided with the distribution.
1330da1778Schristos  *
1430da1778Schristos  * Neither the name of the University nor the names of its contributors
1530da1778Schristos  * may be used to endorse or promote products derived from this software
1630da1778Schristos  * without specific prior written permission.
1730da1778Schristos  *
1830da1778Schristos  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1930da1778Schristos  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
2030da1778Schristos  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2130da1778Schristos  * PURPOSE.
2230da1778Schristos  */
2330da1778Schristos 
2430da1778Schristos /* A reentrant scanner.
2530da1778Schristos    This file will not compile under flex version <= 2.5.4.
2630da1778Schristos    Sample Input:
2730da1778Schristos        # this is a comment
2830da1778Schristos        foo = true
2930da1778Schristos        bar = "string value"
3030da1778Schristos        integer = 43
3130da1778Schristos */
3230da1778Schristos %{
3330da1778Schristos #include "config.h"
3430da1778Schristos %}
3530da1778Schristos 
3630da1778Schristos %option prefix="test"
3730da1778Schristos %option nounput noyywrap noyylineno warn nodefault noinput
3830da1778Schristos %option reentrant
3930da1778Schristos 
4030da1778Schristos IDENT [[:alnum:]_-]
4130da1778Schristos WS    [[:blank:]]
4230da1778Schristos %%
4330da1778Schristos 
4430da1778Schristos ^{IDENT}+{WS}*={WS}*(true|false){WS}*\r?\n    { return 100;}
4530da1778Schristos ^{IDENT}+{WS}*={WS}*\"[^\"\n\r]*\"{WS}*\r?\n  { return 101;}
4630da1778Schristos ^{IDENT}+{WS}*={WS}*[[:digit:]]+{WS}*\r?\n    { return 102;}
4730da1778Schristos ^{WS}*#.*\r?\n     { }
4830da1778Schristos ^{WS}*\r?\n        { }
4930da1778Schristos .|\n  { fprintf(stderr,"Invalid line.\n"); exit(-1);}
5030da1778Schristos 
5130da1778Schristos %%
5230da1778Schristos 
5330da1778Schristos int main(void);
5430da1778Schristos 
55*56bd8546Schristos int main (void)
5630da1778Schristos {
5730da1778Schristos     yyscan_t  lexer;
58*56bd8546Schristos     testlex_init( &lexer );
59*56bd8546Schristos     testset_out ( stdout,lexer);
60*56bd8546Schristos     testset_in  ( stdin, lexer);
61*56bd8546Schristos     while( testlex(lexer) )
6230da1778Schristos     {
6330da1778Schristos     }
64*56bd8546Schristos     testlex_destroy( lexer );
6530da1778Schristos     printf("TEST RETURNING OK.\n");
6630da1778Schristos     return 0;
6730da1778Schristos }
6830da1778Schristos 
69