|
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 |
%{
|
|
Packit |
f00812 |
/* The goal of this test is to verify that we are getting the counter-intuitive
|
|
Packit |
f00812 |
* posix behavior of the repeat operator `{}'.
|
|
Packit |
f00812 |
*
|
|
Packit |
f00812 |
* ab{3} - In traditional flex, this matches "abbb".
|
|
Packit |
f00812 |
* In posix, this matches "ababab".
|
|
Packit |
f00812 |
*/
|
|
Packit |
f00812 |
#include <stdio.h>
|
|
Packit |
f00812 |
#include <stdlib.h>
|
|
Packit |
f00812 |
#include "config.h"
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
#define NUM_TESTS 1
|
|
Packit |
f00812 |
char * tests[NUM_TESTS] = { "ababab"};
|
|
Packit |
f00812 |
int main(void);
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
int tests_ok[NUM_TESTS] = { 0 };
|
|
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 |
ab{3} tests_ok[0] = 1; return 0;
|
|
Packit |
f00812 |
.|\n return 0;
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
%%
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
int main ()
|
|
Packit |
f00812 |
{
|
|
Packit |
f00812 |
YY_BUFFER_STATE state;
|
|
Packit |
f00812 |
int i;
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
yyin = stdin;
|
|
Packit |
f00812 |
yyout = stdout;
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
/* Run the tests */
|
|
Packit |
f00812 |
for (i=0; i < NUM_TESTS; i++){
|
|
Packit |
f00812 |
printf("Testing: yy_scan_string(%s): ", tests[i]);
|
|
Packit |
f00812 |
state = yy_scan_string(tests[i]);
|
|
Packit |
f00812 |
yylex();
|
|
Packit |
f00812 |
yy_delete_buffer(state);
|
|
Packit |
f00812 |
printf("... %s\n", tests_ok[i] ? "OK" : "FAILED");
|
|
Packit |
f00812 |
}
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
for (i=0; i < NUM_TESTS; i++)
|
|
Packit |
f00812 |
if (!tests_ok[i])
|
|
Packit |
f00812 |
exit(1);
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
printf("TEST RETURNING OK.\n");
|
|
Packit |
f00812 |
return 0;
|
|
Packit |
f00812 |
}
|