|
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 |
/* The point of this test is to be sure our M4 madness does not
|
|
Packit |
f00812 |
* interfere with user code. I particular, we are looking
|
|
Packit |
f00812 |
* for instances of M4 quotes, [[ and ]], in here to make it through the flex
|
|
Packit |
f00812 |
* machinery unscathed.
|
|
Packit |
f00812 |
*/
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
/* sect 1 [ 1 ] TEST_XXX */
|
|
Packit |
f00812 |
/* sect 1 [[ 2 ]] TEST_XXX */
|
|
Packit |
f00812 |
/* sect 1 [[[ 3 ]]] TEST_XXX */
|
|
Packit |
f00812 |
/* sect 1 [[[[ 4 ]]]] TEST_XXX */
|
|
Packit |
f00812 |
/* sect 1 ]] unmatched [[ TEST_XXX */
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
%{
|
|
Packit |
f00812 |
/* A template scanner file to build "scanner.c". */
|
|
Packit |
f00812 |
#include <stdio.h>
|
|
Packit |
f00812 |
#include <stdlib.h>
|
|
Packit |
f00812 |
#include "config.h"
|
|
Packit |
f00812 |
/*#include "parser.h" */
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
/* sect 1 block [ 1 ] TEST_XXX */
|
|
Packit |
f00812 |
/* sect 1 block [[ 2 ]] TEST_XXX */
|
|
Packit |
f00812 |
/* sect 1 block [[[ 3 ]]] TEST_XXX */
|
|
Packit |
f00812 |
/* sect 1 block [[[[ 4 ]]]] TEST_XXX */
|
|
Packit |
f00812 |
/* sect 1 block ]] unmatched [[ TEST_XXX */
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
static int a[1] = {0};
|
|
Packit |
f00812 |
static int b[1] = {0};
|
|
Packit |
f00812 |
static int c[1] = {0};
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
static int foo (int i){
|
|
Packit |
f00812 |
return a[b[c[i]]]; /* sect 1 code TEST_XXX */
|
|
Packit |
f00812 |
}
|
|
Packit |
f00812 |
%}
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
%option 8bit prefix="test"
|
|
Packit |
f00812 |
%option nounput nomain noyywrap noinput
|
|
Packit |
f00812 |
%option warn
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
%%
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
a /* action comment [ 1 ] */ ;
|
|
Packit |
f00812 |
b /* action comment [[ 2 ]] */ ;
|
|
Packit |
f00812 |
c /* action comment [[[ 3 ]]] */ ;
|
|
Packit |
f00812 |
d /* action comment [[[[ 4 ]]]] */ ;
|
|
Packit |
f00812 |
e /* action comment ]] unmatched [[ */ ;
|
|
Packit |
f00812 |
f return 1+foo(a[b[c[0]]]);
|
|
Packit |
f00812 |
.|\n {
|
|
Packit |
f00812 |
/* action block [ 1 ] TEST_XXX */
|
|
Packit |
f00812 |
/* action block [[ 2 ]] TEST_XXX */
|
|
Packit |
f00812 |
/* action block [[[ 3 ]]] TEST_XXX */
|
|
Packit |
f00812 |
/* action block [[[[ 4 ]]]] TEST_XXX */
|
|
Packit |
f00812 |
/* action block ]] unmatched [[ TEST_XXX */
|
|
Packit |
f00812 |
return 1+foo(a[b[c[0]]]); // TEST_XXX
|
|
Packit |
f00812 |
}
|
|
Packit |
f00812 |
%%
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
/* sect 3 [ 1 ] TEST_XXX */
|
|
Packit |
f00812 |
/* sect 3 [[ 2 ]] TEST_XXX */
|
|
Packit |
f00812 |
/* sect 3 [[[ 3 ]]] TEST_XXX */
|
|
Packit |
f00812 |
/* sect 3 [[[[ 4 ]]]] TEST_XXX */
|
|
Packit |
f00812 |
/* sect 3 ]] unmatched [[ TEST_XXX */
|
|
Packit |
f00812 |
static int bar (int i){
|
|
Packit |
f00812 |
return c[b[a[i]]]; /* sect 3 code TEST_XXX */
|
|
Packit |
f00812 |
}
|
|
Packit |
f00812 |
int main(void);
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
int
|
|
Packit |
f00812 |
main ()
|
|
Packit |
f00812 |
{
|
|
Packit |
f00812 |
yyin = stdin;
|
|
Packit |
f00812 |
yyout = stdout;
|
|
Packit |
f00812 |
while (yylex())
|
|
Packit |
f00812 |
;
|
|
Packit |
f00812 |
printf("TEST RETURNING OK.\n");
|
|
Packit |
f00812 |
return bar(0);
|
|
Packit |
f00812 |
}
|
|
Packit |
f00812 |
|