1 1.1 christos /* 2 1.1 christos * This file is part of flex. 3 1.1 christos * 4 1.1 christos * Redistribution and use in source and binary forms, with or without 5 1.1 christos * modification, are permitted provided that the following conditions 6 1.1 christos * are met: 7 1.1 christos * 8 1.1 christos * 1. Redistributions of source code must retain the above copyright 9 1.1 christos * notice, this list of conditions and the following disclaimer. 10 1.1 christos * 2. Redistributions in binary form must reproduce the above copyright 11 1.1 christos * notice, this list of conditions and the following disclaimer in the 12 1.1 christos * documentation and/or other materials provided with the distribution. 13 1.1 christos * 14 1.1 christos * Neither the name of the University nor the names of its contributors 15 1.1 christos * may be used to endorse or promote products derived from this software 16 1.1 christos * without specific prior written permission. 17 1.1 christos * 18 1.1 christos * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 19 1.1 christos * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 20 1.1 christos * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 1.1 christos * PURPOSE. 22 1.1 christos */ 23 1.1 christos 24 1.1 christos /* A reentrant scanner. 25 1.1 christos This file will not compile under flex version <= 2.5.4. 26 1.1 christos Sample Input: 27 1.1 christos # this is a comment 28 1.1 christos foo = true 29 1.1 christos bar = "string value" 30 1.1 christos integer = 43 31 1.1 christos */ 32 1.1 christos %{ 33 1.1 christos #include "config.h" 34 1.1 christos %} 35 1.1 christos 36 1.1 christos %option prefix="test" 37 1.1 christos %option nounput noyywrap noyylineno warn nodefault noinput 38 1.1 christos %option reentrant 39 1.1 christos 40 1.1 christos IDENT [[:alnum:]_-] 41 1.1 christos WS [[:blank:]] 42 1.1 christos %% 43 1.1 christos 44 1.1 christos ^{IDENT}+{WS}*={WS}*(true|false){WS}*\r?\n { return 100;} 45 1.1 christos ^{IDENT}+{WS}*={WS}*\"[^\"\n\r]*\"{WS}*\r?\n { return 101;} 46 1.1 christos ^{IDENT}+{WS}*={WS}*[[:digit:]]+{WS}*\r?\n { return 102;} 47 1.1 christos ^{WS}*#.*\r?\n { } 48 1.1 christos ^{WS}*\r?\n { } 49 1.1 christos .|\n { fprintf(stderr,"Invalid line.\n"); exit(-1);} 50 1.1 christos 51 1.1 christos %% 52 1.1 christos 53 1.1 christos int main(void); 54 1.1 christos 55 1.1.1.2 christos int main (void) 56 1.1 christos { 57 1.1 christos yyscan_t lexer; 58 1.1.1.2 christos testlex_init( &lexer ); 59 1.1.1.2 christos testset_out ( stdout,lexer); 60 1.1.1.2 christos testset_in ( stdin, lexer); 61 1.1.1.2 christos while( testlex(lexer) ) 62 1.1 christos { 63 1.1 christos } 64 1.1.1.2 christos testlex_destroy( lexer ); 65 1.1 christos printf("TEST RETURNING OK.\n"); 66 1.1 christos return 0; 67 1.1 christos } 68 1.1 christos 69