473,545 Members | 2,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

2 New Member
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 2957
Dormilich
8,658 Recognized Expert Moderator Expert
@latif87
good luck. please do tell me, how you could work it out.
Sep 14 '09 #2
latif87
2 New Member
so u have no idea about it! can u look for someone who might help me out
Sep 14 '09 #3
Dormilich
8,658 Recognized Expert Moderator Expert
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
5481
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. Anyone have any thoughts? -- Simon Foster Somewhere in the West of England
6
3992
by: Eddie Smit | last post by:
field- field- surname town ---- ---- john NY john Vegas john Boston eddie Boston eddie New Orleans eddie NY
4
6332
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 !='"') warning("Undeterminated Character strig",(char *)0); else
4
4884
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 ? Thanks. -- Rodrick R. Brown
4
2113
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) and the Language Objects Library) that I have converted over to C#. It works okay. However, in the C# version, one has to build the class library...
6
2729
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 it up to here (funny hand gesture) with trying to compile the bullet-riddled code that GNU Flex and Bison keep spitting out for even the simplest of...
13
5007
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 a question regarding the dynamic memory allocation for strings. When the lex file encounters a variable name, I want it to pass this to yacc...
1
1910
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 a different file, one that has no syntax errors. When I try to open this second file, yacc throws me another error which I believe is leftover from...
1
2017
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 lex/yacc suit that purpose - i.e. kind of like a tree-manufacturing C library? Or is it for producing a compiler/interpreter the internals of which a new...
0
7502
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7692
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7791
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5360
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3491
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1921
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
744
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.