Connecting Tech Pros Worldwide Help | Site Map

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

Newbie
 
Join Date: Sep 2009
Posts: 2
#1: Sep 14 '09
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
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,631
#2: Sep 14 '09

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


Quote:

Originally Posted by latif87 View Post

Develop a scanner for the XML configuration file specified before.

good luck. please do tell me, how you could work it out.
Newbie
 
Join Date: Sep 2009
Posts: 2
#3: Sep 14 '09

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


so u have no idea about it! can u look for someone who might help me out
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,631
#4: Sep 14 '09

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


sorry, but I have no idea about software development, nor do I know someone thereof.
Reply