473,387 Members | 1,431 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,387 software developers and data experts.

how to make scanner in lexer/yacc for farm town in xml

An example of how the XML file is structured:
Expand|Select|Wrap|Line Numbers
  1. <xml>
  2. <farm name="NAME1">
  3. <size x="INTEGER1" y="INTEGER2" />
  4. <neighbor name="NAME2" />
  5. <crop name="PLANT" area="INTEGER3" />
  6. <crop … />
  7. </farm>
  8. <farm name="NAME2" …>
  9. </farm>
  10. </xml>

Develop a scanner for the XML configuration file specified before. Remember that the scanner just
splits the grammar up into tokens.
Below is a list of categories that you will need to use in your scanner.
Category ← Tokens that fall in that category
Start Tag ← <xml, <farm, <size <neighbor, <crop
End Start Tag ← >
End Tag ← </xml>, </farm>, />
Attribute ← name, x, y, area
Assignment ← =
Number ← Any integer
String ← Anything within double quotes
White space characters should be ignored in the program.
If an invalid token is read, the error message “Invalid Token: T” should be displayed, where T is the
invalid token that was read. After an error occurs, the program should continue parsing the file.
Your lex file will need to output: matched category, colon, matched token, and a line return.
For example, the input:
Expand|Select|Wrap|Line Numbers
  1. <xml>
  2. <farm name="John">
  3. <size x="2" y="3" />
  4. </farm>
  5. </xml>
Would output:
Start Tag: <xml
End Start Tag: >
Start Tag: <farm
Attribute: name
Assignment: =
String: “John”
End Start Tag: >
Start Tag: <size
Sep 14 '09 #1
3 2947
Dormilich
8,658 Expert Mod 8TB
@latif87
good luck. please do tell me, how you could work it out.
Sep 14 '09 #2
so u have no idea about it! can u look for someone who might help me out
Sep 14 '09 #3
Dormilich
8,658 Expert Mod 8TB
sorry, but I have no idea about software development, nor do I know someone thereof.
Sep 14 '09 #4

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

Similar topics

3
by: Simon Foster | last post by:
Anyone have any experience or pointers to how to go about creating a parser lexer for assemble in Python. I was thinking of using PLY but wonder whether it's too heavyweight for what I want. ...
6
by: Eddie Smit | last post by:
field- field- surname town ---- ---- john NY john Vegas john Boston eddie Boston eddie New Orleans eddie NY
4
by: Profetas | last post by:
Hi. I was wondering how can I access the yacc functions? because when use a normal yacc function such as qstring { yylval.string = strdup(yytext+1); if(yylval.string !='"')...
4
by: Rodrick Brown | last post by:
This might be off topic but can someone give me a quick run down on why tools like lexx/yacc/bison are usefull ? I know what there used for but not sure when they should be used and where ? ...
4
by: Chris F Clark | last post by:
Please excuse the length of this post, I am unfortunately long-winded, and don't know how to make my postings more brief. I have a C++ class library (and application generator, called Yacc++(r)...
6
by: Mike C# | last post by:
Hi all, Can anyone recommend a good and *easy to use* lexer and parser generator? Preferably one that was written specifically for VC++ and not mangled through 20 different platforms. I've had...
13
by: Berk Birand | last post by:
Hi, I am working on a school project where we use lex/yacc to write a compiler for a fictional (Java-like) language. I have handled all the details about the yacc and lex files, but I still have...
1
by: neena.usenet | last post by:
I have a gui that reads in a file using C++/yacc. If the file has a parsing error, yacc throws the error to my program and I report it. The problem is at that point, I would like to try to open...
1
by: Robert | last post by:
If the goal is to take a 1-dimensional package of text and produce a tree data structure that is easy to understand and manipulate, and then write C/C++ code that works with that tree - does...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.