473,383 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

parsing problem with lex/yacc - yylval returns unintended value for $1

Hi Folks,
I am writing a simple parser to parse SPICE code ( Spice is a transistor level simulator ). The spice code looks like this -
========================
R10 2 3 0.5e-3
C11 4 6 0.2e-6
L13 4 4 0.1e-9
=========================
As you can see each line has 4 items -
a character string followed by an integer then another integer and finally a floating point number.
I need to return the appropriate token on a per line basis.

I am attaching a tar ball called parse.zip that has the following files -
1. netlist ( the source file to be parsed )
2. spice.lex ( the lexer code )
3. spice.y ( the grammar )
4. Makefile

To build the parser, simple type make ( on linux ). Then to run -
%parser < netlist

In the .y file I have the grammar rule where I expect $1 to return the character string, $2 to return the first integer, $3 to return the next integer value and finally $4 to return the floating point value on a per line basis. Mos of this works correctly, except $1 returns the entire line instead of the character string. Can anyone tell what's wrong in the token generator ( lex file ) or the grammar description ( .y file ) ?? Any help will be highly appreciated.

Thanks,

Rajat Mitra
Attached Files
File Type: zip parse.zip (1.8 KB, 97 views)
Jun 2 '10 #1
0 1780

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Edward | last post by:
I have the following function to determine if a form is loaded: Public Function modIsloaded(ByVal vstrFormName As String) As Boolean ' Error handling removed for concision ' Determine if...
1
by: Jean Stax | last post by:
Hi ! I created a sample library project. In my second project I reference this library and make the following call, which returns "undefined value": Type myType =...
3
by: Stephan | last post by:
Hi, I'm working on a page with multiple Datalist-controls on it. The problem I'm facing is that when I try to update a record, the ItemIndex returns a value which is one lower than the Item I...
12
by: chellappa | last post by:
hi All, function automatically returns the value,am not used "return" i am using Linux -gcc complier please tell me.... what is problem... source ===== #include <stdio.h> main() {
2
by: nikolacace | last post by:
Hi, I have a stored procedure (the code is below) that I use to retrieve one value from my database. I tested the code in Query Analyzer, and it works (I get the value I was looking for). However,...
3
by: ApexData | last post by:
Hello I completed an application that worked great until I went to STARTUP and shut off all of the checkboxes. My code uses "Application.CurrentObjectName" to get the current Form name. All my...
3
by: anupamsps | last post by:
HI all, This is my first posting in this forum. I am confused about how to write a function that returns a value rounded to the nearest value of a double variable say X. when X is positive...
2
by: O.B. | last post by:
I have a C# Socket configured for streaming TCP. Upon making a valid connection, I have an asynchronous callback configured using BeginReceive. Within the BeginReceive declaration, I set the...
9
by: =?utf-8?b?QXNiasO4cm4gU8OmYsO4?= | last post by:
I am replacing a number of functions with macros. Some of these functions "do something" and then return a variable. This behaviour I have found that I can emulate using the comma operator: ...
13
by: mcfly1204 | last post by:
The following query only returns one value when several are expected. SELECT @contactid = Con.CONTACTID, @accountid = Con.ACCOUNTID, @lastname = LASTNAME, @firstname = FIRSTNAME, @email = EMAIL,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.