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 /* TEST scanner. 25 1.1 christos Basic non-reentrant scanner. 26 1.1 christos 27 1.1 christos Sample Input: 28 1.1 christos # this is a comment 29 1.1 christos foo = true 30 1.1 christos bar = "string value" 31 1.1 christos integer = 43 32 1.1 christos */ 33 1.1 christos %{ 34 1.1 christos #include "config.h" 35 1.1 christos %} 36 1.1 christos 37 1.1 christos %option prefix="test" 38 1.1 christos %option nounput noyywrap noyylineno warn nodefault noinput 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 yyin = stdin; 58 1.1 christos yyout = stdout; 59 1.1 christos while( yylex() ) 60 1.1 christos { 61 1.1 christos } 62 1.1 christos printf("TEST RETURNING OK.\n"); 63 1.1 christos return 0; 64 1.1 christos } 65