2 * This file is part of flex.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * Neither the name of the University nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 /* The point of this test is to be sure our M4 madness does not
25 * interfere with user code. I particular, we are looking
26 * for instances of M4 quotes, [[ and ]], in here to make it through the flex
27 * machinery unscathed.
30 /* sect 1 [ 1 ] TEST_XXX */
31 /* sect 1 [[ 2 ]] TEST_XXX */
32 /* sect 1 [[[ 3 ]]] TEST_XXX */
33 /* sect 1 [[[[ 4 ]]]] TEST_XXX */
34 /* sect 1 ]] unmatched [[ TEST_XXX */
37 /* A template scanner file to build "scanner.c". */
41 /*#include "parser.h" */
43 /* sect 1 block [ 1 ] TEST_XXX */
44 /* sect 1 block [[ 2 ]] TEST_XXX */
45 /* sect 1 block [[[ 3 ]]] TEST_XXX */
46 /* sect 1 block [[[[ 4 ]]]] TEST_XXX */
47 /* sect 1 block ]] unmatched [[ TEST_XXX */
49 static int a[1] = {0};
50 static int b[1] = {0};
51 static int c[1] = {0};
53 static int foo (int i){
54 return a[b[c[i]]]; /* sect 1 code TEST_XXX */
58 %option 8bit outfile="scanner.c" prefix="test"
59 %option nounput nomain noyywrap
65 a /* action comment [ 1 ] */ ;
66 b /* action comment [[ 2 ]] */ ;
67 c /* action comment [[[ 3 ]]] */ ;
68 d /* action comment [[[[ 4 ]]]] */ ;
69 e /* action comment ]] unmatched [[ */ ;
70 f return 1+foo(a[b[c[0]]]);
72 /* action block [ 1 ] TEST_XXX */
73 /* action block [[ 2 ]] TEST_XXX */
74 /* action block [[[ 3 ]]] TEST_XXX */
75 /* action block [[[[ 4 ]]]] TEST_XXX */
76 /* action block ]] unmatched [[ TEST_XXX */
77 return 1+foo(a[b[c[0]]]); // TEST_XXX
81 /* sect 3 [ 1 ] TEST_XXX */
82 /* sect 3 [[ 2 ]] TEST_XXX */
83 /* sect 3 [[[ 3 ]]] TEST_XXX */
84 /* sect 3 [[[[ 4 ]]]] TEST_XXX */
85 /* sect 3 ]] unmatched [[ TEST_XXX */
86 static int bar (int i){
87 return c[b[a[i]]]; /* sect 3 code TEST_XXX */
98 printf("TEST RETURNING OK.\n");