- Remove unused files
git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4504 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
@@ -1,181 +0,0 @@
|
|||||||
/* For development only : */
|
|
||||||
%debug
|
|
||||||
%error-verbose
|
|
||||||
|
|
||||||
/* Keep track of location */
|
|
||||||
%locations
|
|
||||||
%defines
|
|
||||||
%pure-parser
|
|
||||||
|
|
||||||
%{
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include "parser.h"
|
|
||||||
|
|
||||||
int
|
|
||||||
yyerror(const char *msg);
|
|
||||||
|
|
||||||
extern int yywrap();
|
|
||||||
extern int yylex();
|
|
||||||
|
|
||||||
extern int yylineno;
|
|
||||||
|
|
||||||
/* The Lex parser prototype */
|
|
||||||
int fddlex(YYSTYPE *lvalp, YYLTYPE *llocp);
|
|
||||||
%}
|
|
||||||
|
|
||||||
/* Values returned by lex for token */
|
|
||||||
%union {
|
|
||||||
char *string; /* The string is allocated by strdup in lex.*/
|
|
||||||
int integer; /* Store integer values */
|
|
||||||
}
|
|
||||||
|
|
||||||
%token LEX_ERROR
|
|
||||||
|
|
||||||
%token <string> QSTRING
|
|
||||||
%token <string> STRING
|
|
||||||
%token <integer> INTEGER
|
|
||||||
%token Y_TYPEDEF
|
|
||||||
%token Y_STRUCT
|
|
||||||
%token Y_UNION
|
|
||||||
%token Y_CHARTYPE
|
|
||||||
%token Y_SHORTTYPE
|
|
||||||
%token Y_INTTYPE
|
|
||||||
%token Y_LONGTYPE
|
|
||||||
%token Y_ENUM
|
|
||||||
%token Y_UNSIGNED
|
|
||||||
%token Y_SIGNED
|
|
||||||
%token Y_EXTENSION
|
|
||||||
%token Y_ATTRIBUTE
|
|
||||||
%token Y_ATTRIBUTE_MODE
|
|
||||||
%token Y_ATTRIBUTE_HI
|
|
||||||
%token Y_ATTRIBUTE_SI
|
|
||||||
%token Y_VOIDTYPE
|
|
||||||
%token Y_POINTER
|
|
||||||
%token Y_SIZEOF
|
|
||||||
|
|
||||||
%%
|
|
||||||
messages:
|
|
||||||
| messages definition
|
|
||||||
| messages errors
|
|
||||||
{
|
|
||||||
yyerror("An error occurred while parsing the configuration file");
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
definition:
|
|
||||||
| Y_EXTENSION definition
|
|
||||||
| Y_TYPEDEF enumerate
|
|
||||||
| Y_TYPEDEF structure
|
|
||||||
| structure
|
|
||||||
| enumerate
|
|
||||||
| Y_STRUCT STRING ';'
|
|
||||||
| Y_TYPEDEF singletype attribute ';'
|
|
||||||
;
|
|
||||||
|
|
||||||
enumerate:
|
|
||||||
| Y_ENUM '{' enumlist '}' STRING ';'
|
|
||||||
| Y_ENUM STRING '{' enumlist '}' ';'
|
|
||||||
| Y_ENUM STRING '{' enumlist '}' STRING ';'
|
|
||||||
;
|
|
||||||
|
|
||||||
enumlist:
|
|
||||||
| enumitem ',' enumlist
|
|
||||||
| enumitem
|
|
||||||
;
|
|
||||||
|
|
||||||
enumitem: STRING '=' INTEGER
|
|
||||||
| STRING '=' STRING
|
|
||||||
| STRING
|
|
||||||
;
|
|
||||||
|
|
||||||
structure: Y_STRUCT STRING '{' paramlist '}' STRING ';'
|
|
||||||
| Y_STRUCT '{' paramlist '}' STRING ';'
|
|
||||||
| Y_STRUCT STRING '{' paramlist '}' ';'
|
|
||||||
| Y_STRUCT STRING ';'
|
|
||||||
| Y_STRUCT STRING STRING attribute ';'
|
|
||||||
| Y_STRUCT singletype ';'
|
|
||||||
;
|
|
||||||
|
|
||||||
paramlist:
|
|
||||||
| paramlist singletype ';'
|
|
||||||
| paramlist union
|
|
||||||
| paramlist structure
|
|
||||||
;
|
|
||||||
|
|
||||||
union: Y_UNION STRING '{' paramlist '}' STRING ';'
|
|
||||||
| Y_UNION '{' paramlist '}' STRING ';'
|
|
||||||
| Y_UNION STRING '{' paramlist '}' ';'
|
|
||||||
;
|
|
||||||
|
|
||||||
singletype:
|
|
||||||
| Y_SIGNED singletype
|
|
||||||
| Y_UNSIGNED singletype
|
|
||||||
| STRING STRING
|
|
||||||
| Y_CHARTYPE STRING
|
|
||||||
| Y_SHORTTYPE STRING
|
|
||||||
| Y_INTTYPE STRING
|
|
||||||
| Y_SHORTTYPE Y_INTTYPE STRING
|
|
||||||
| Y_LONGTYPE STRING
|
|
||||||
| Y_LONGTYPE Y_INTTYPE STRING
|
|
||||||
| Y_LONGTYPE Y_LONGTYPE Y_INTTYPE STRING
|
|
||||||
| Y_VOIDTYPE Y_POINTER STRING
|
|
||||||
| Y_VOIDTYPE STRING
|
|
||||||
| STRING Y_POINTER STRING
|
|
||||||
| basictype Y_POINTER STRING
|
|
||||||
| singletype '[' arraydef ']'
|
|
||||||
| structure
|
|
||||||
;
|
|
||||||
|
|
||||||
arraydef:
|
|
||||||
| INTEGER arraydef
|
|
||||||
| '*' arraydef
|
|
||||||
| Y_POINTER arraydef
|
|
||||||
| Y_SIZEOF arraydef
|
|
||||||
| '(' arraydef
|
|
||||||
| ')' arraydef
|
|
||||||
| basictype arraydef
|
|
||||||
| '-' arraydef
|
|
||||||
| STRING arraydef
|
|
||||||
;
|
|
||||||
|
|
||||||
attribute:
|
|
||||||
| Y_ATTRIBUTE '(' attributevalue ')'
|
|
||||||
;
|
|
||||||
|
|
||||||
attributevalue:
|
|
||||||
| '(' Y_ATTRIBUTE_MODE attributeparam ')'
|
|
||||||
| Y_ATTRIBUTE_MODE attributeparam
|
|
||||||
;
|
|
||||||
|
|
||||||
attributeparam:
|
|
||||||
| '(' Y_ATTRIBUTE_HI ')'
|
|
||||||
| '(' Y_ATTRIBUTE_SI ')'
|
|
||||||
;
|
|
||||||
|
|
||||||
basictype:
|
|
||||||
| Y_CHARTYPE
|
|
||||||
| Y_SHORTTYPE
|
|
||||||
| Y_INTTYPE
|
|
||||||
| Y_LONGTYPE
|
|
||||||
| Y_VOIDTYPE
|
|
||||||
;
|
|
||||||
|
|
||||||
/* Lexical or syntax error */
|
|
||||||
errors: LEX_ERROR
|
|
||||||
| error
|
|
||||||
;
|
|
||||||
|
|
||||||
%%
|
|
||||||
|
|
||||||
int
|
|
||||||
yyerror(const char *msg) {
|
|
||||||
extern char *yytext;
|
|
||||||
fprintf(stderr,
|
|
||||||
"Parse error near line %d (token \"%s\"): %s\n",
|
|
||||||
yylineno, yytext, msg);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
@@ -1,123 +0,0 @@
|
|||||||
|
|
||||||
/* Lex configuration parser.
|
|
||||||
*
|
|
||||||
* This file defines the token for parsing the configuration file
|
|
||||||
*
|
|
||||||
* Note : This module is NOT thread-safe. All processing must be done from one thread only.
|
|
||||||
*/
|
|
||||||
%{
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
/* Include yacc tokens definitions */
|
|
||||||
#include "parser.h"
|
|
||||||
|
|
||||||
/* Update the column information */
|
|
||||||
#ifdef DEBUG_LEX
|
|
||||||
#define YY_USER_ACTION { \
|
|
||||||
yylloc->first_column = yylloc->last_column + 1; \
|
|
||||||
yylloc->last_column = yylloc->first_column + yyleng - 1; \
|
|
||||||
TRACE_DEBUG(FULL, \
|
|
||||||
"(%d:%d-%d:%d) matched rule %d, length=%d, txt='%s'\n", \
|
|
||||||
yylloc->first_line, yylloc->first_column, \
|
|
||||||
yylloc->last_line, yylloc->last_column, \
|
|
||||||
yy_act, yyleng, yytext); \
|
|
||||||
}
|
|
||||||
#else /* DEBUG_LEX */
|
|
||||||
#define YY_USER_ACTION { \
|
|
||||||
yylloc->first_column = yylloc->last_column + 1; \
|
|
||||||
yylloc->last_column = yylloc->first_column + yyleng - 1; \
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define YY_NO_INPUT
|
|
||||||
%}
|
|
||||||
|
|
||||||
%option bison-bridge bison-locations
|
|
||||||
%option noyywrap
|
|
||||||
%option nounput
|
|
||||||
%option yylineno
|
|
||||||
|
|
||||||
/* Quoted string. Multilines do not match. */
|
|
||||||
qstring \"[^\"\n]*\"
|
|
||||||
|
|
||||||
%%
|
|
||||||
|
|
||||||
/* List of patterns and actions */
|
|
||||||
|
|
||||||
<*>\n {
|
|
||||||
/* Update the line count */
|
|
||||||
yylloc->first_line++;
|
|
||||||
yylloc->last_line++;
|
|
||||||
yylloc->last_column=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
<*>([[:space:]]{-}[\n])+ ; /* Eat all spaces, not new lines */
|
|
||||||
<*>#.*$ ; /* Eat all comments */
|
|
||||||
|
|
||||||
/* Full words tokens (keywords) */
|
|
||||||
(?i:"typedef") { return Y_TYPEDEF; }
|
|
||||||
(?i:"struct") { return Y_STRUCT; }
|
|
||||||
(?i:"union") { return Y_UNION; }
|
|
||||||
(?i:"enum") { return Y_ENUM; }
|
|
||||||
(?i:"signed") { return Y_SIGNED; }
|
|
||||||
(?i:"unsigned") { return Y_UNSIGNED; }
|
|
||||||
(?i:"short") { return Y_SHORTTYPE; }
|
|
||||||
(?i:"char") { return Y_CHARTYPE; }
|
|
||||||
(?i:"int") { return Y_INTTYPE; }
|
|
||||||
(?i:"long") { return Y_LONGTYPE; }
|
|
||||||
(?i:"void") { return Y_VOIDTYPE; }
|
|
||||||
(?i:"__extension__") { return Y_EXTENSION; }
|
|
||||||
(?i:"__attribute__") { return Y_ATTRIBUTE; }
|
|
||||||
(?i:"__mode__") { return Y_ATTRIBUTE_MODE; }
|
|
||||||
(?i:"__HI__") { return Y_ATTRIBUTE_HI; }
|
|
||||||
(?i:"__SI__") { return Y_ATTRIBUTE_SI; }
|
|
||||||
(?i:"sizeof") { return Y_SIZEOF; }
|
|
||||||
|
|
||||||
[A-Za-z_][A-Za-z0-9_]* {
|
|
||||||
/* First copy the string without the quotes for use in the yacc parser */
|
|
||||||
if ((yylval->string = strdup(yytext+1)) == NULL) { /* This allocates one useless tail char but... it's easier :D */
|
|
||||||
return LEX_ERROR;/* on error, trig an error in yacc parser */
|
|
||||||
}
|
|
||||||
yylval->string[yyleng-2] = '\0';
|
|
||||||
|
|
||||||
/* the yacc parser will check the string is valid */
|
|
||||||
return STRING;
|
|
||||||
}
|
|
||||||
|
|
||||||
{qstring} {
|
|
||||||
/* First copy the string without the quotes for use in the yacc parser */
|
|
||||||
if ((yylval->string = strdup(yytext+1)) == NULL) { /* This allocates one useless tail char but... it's easier :D */
|
|
||||||
return LEX_ERROR;/* on error, trig an error in yacc parser */
|
|
||||||
}
|
|
||||||
yylval->string[yyleng-2] = '\0';
|
|
||||||
|
|
||||||
/* the yacc parser will check the string is valid */
|
|
||||||
return QSTRING;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[:digit:]]+ {
|
|
||||||
/* Convert this to an integer value */
|
|
||||||
int ret = sscanf(yytext, "%i", &yylval->integer);
|
|
||||||
if (ret != 1) {
|
|
||||||
/* No matching: an error occurred */
|
|
||||||
fprintf(stderr, "Unable to convert the value '%s' to a valid number: %s\n",
|
|
||||||
yytext, strerror(errno));
|
|
||||||
return LEX_ERROR; /* trig an error in yacc parser */
|
|
||||||
/* Maybe we could REJECT instead of failing here? */
|
|
||||||
}
|
|
||||||
return INTEGER;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Valid single characters for yyparse */
|
|
||||||
<*>[\-+=,:;{}\[\]\(\)] { return yytext[0]; }
|
|
||||||
<*>[*]* { return Y_POINTER; }
|
|
||||||
|
|
||||||
<*>[[:alnum:]]+ | /* This rule is only useful to print a complete token in error messages */
|
|
||||||
/* Unrecognized character */
|
|
||||||
<*>. {
|
|
||||||
fprintf(stderr, "Unrecognized text on line %d col %d: '%s'.\n",
|
|
||||||
yylloc->first_line, yylloc->first_column, yytext);
|
|
||||||
return LEX_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
%%
|
|
||||||
Reference in New Issue
Block a user