|
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 scanner expects to link to bison yylval . */
|
|
Packit |
f00812 |
#include <stdio.h>
|
|
Packit |
f00812 |
#include <stdlib.h>
|
|
Packit |
f00812 |
#include "bison_nr_parser.h"
|
|
Packit |
f00812 |
#include "config.h"
|
|
Packit |
f00812 |
static char* STRDUP(char* s1);
|
|
Packit |
f00812 |
#define YY_EXTRA_TYPE int
|
|
Packit |
f00812 |
%}
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
%option 8bit prefix="test"
|
|
Packit |
f00812 |
%option bison-locations yylineno
|
|
Packit |
f00812 |
%option prefix="test" header="bison_nr_scanner.h" yylineno
|
|
Packit |
f00812 |
%option nomain nounput noyy_top_state noyywrap nodefault noinput warn
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
%%
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
^[[:digit:]]+ {
|
|
Packit |
f00812 |
yylval->lineno = yylineno;
|
|
Packit |
f00812 |
yylloc->first_line = (int)strtol(yytext,NULL,10);
|
|
Packit |
f00812 |
return LINENO;
|
|
Packit |
f00812 |
}
|
|
Packit |
f00812 |
":" { return COLON; }
|
|
Packit |
f00812 |
" " { return SPACE; }
|
|
Packit |
f00812 |
"=" { return EQUAL; }
|
|
Packit |
f00812 |
[[:alnum:]_]+ { yylval->str = STRDUP(yytext); return IDENT;}
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
\r|\n { }
|
|
Packit |
f00812 |
. { yyterminate();}
|
|
Packit |
f00812 |
%%
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
|
|
Packit |
f00812 |
static char* STRDUP(char* s1)
|
|
Packit |
f00812 |
{
|
|
Packit |
f00812 |
char* s2 = malloc(strlen(s1)+1);
|
|
Packit |
f00812 |
sprintf(s2,"%s",s1);
|
|
Packit |
f00812 |
return s2;
|
|
Packit |
f00812 |
}
|