[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Parsing help
From: |
Sriram Bhamidipati |
Subject: |
Parsing help |
Date: |
Tue, 17 Feb 2004 12:37:21 +0530 |
Hi all
this is very lame problem but I am not able to solve
%{
int arr[40];int i,j;
char rt1[30], rt2[30];
# define I_ROUTE 257
%}
%union {
char* name; /* For returning route names */
int nval; /* For returning numbers */
}
%token <name> I_ROUTE
%token <nval> NUM
%type <name> I_ROUTE
%type <name> route
%type <name> format
%%
format : route
;
route : I_ROUTE {strcpy(rt1, $1);} NUM { printf(">%s\n", $$);}
|I_ROUTE {strcpy(rt1, $1);} I_ROUTE {strcpy(rt2, $1);}
NUM
;
%%
The above is not working as I wanted . I basically want to parse
E 3
ES 3
ER TF 4 5 6
etc
The result should be that I be able to store the Route Name with the values
(Route Name is E, ES, "ER TF" etc
when I do strcpy, I am getting the result of the next token and not the
current token
Can someone suggest a change in grammar ? Or explain whats the mistake ?
thanks
sriram
- Parsing help,
Sriram Bhamidipati <=