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

XML LL(1) grammar

3
Has anybody tried to rewrite the whole XML EBNF grammar to LL(1) form? I try to write recursive descent parser...but i have some problems. Can anybody show me LL(1) grammar for XML, something like:

1.)element → [<] · name · attribute_list · element_suffix
2.) element_suffix → [/] · [>]
3.) element_suffix → [>] · element · [<] · [/] · [name] · [>]
4.) attribute_list → [space] · attribute_list_suffix
5.) attribute_list → ε
6.) attribute_list_suffix → attribute · attribute_list
7.) attribute → name · optional_space · [=] · optional_space · attribute_value
8.) attribute_value → ["] · [id] · ["]
9.) attribute_value → ['] · [id] · [']
10.) optional_space → [space]
11.) optional_space → ε
.
.
.
Thanks
Mar 12 '07 #1
3 3409
dorinbogdan
839 Expert 512MB
Welcome to TSDN,

I never dealed with XML grammar issues, and have not seen questions/answers related to LL(1) or EBNF.
However you may find helpful the reference from this XML tutorial, if it is not already known to you.
For a more comprehensive book, see also
Advanced XML programming
Mar 12 '07 #2
Swip
1
Hi,

i am currently trying to parse XML with a hand written ll(1) parser. The problem is, that the XML spec productions are in a special EBNF notation, as you already mentioned. So, my approach would be to transform some productions into others and to add some more necessary. I think, the main problem are the +, * and ?:

?: (optional),
{0,1}
A --> B?
B --> B | (epsilon)

*: (optional repetition), {0,1,2,3,...}
A --> B*
B --> B | B B | (epsilon)

+: (repetition), {1,2,3,...}
A --> B+
B --> B | B B


With the ablove example transformations, I would do something of the following for the rest of all productions:

the XML spec production:
[1] document --> prolog element Misc*

the transformed production set:
document --> prolog element Misc
Misc --> Misc Misc
Misc --> Misc
Misc --> (epsilon)

Hope, that I am on the right way. Otherwise please leave a note.

Best regards,
Swip

(P.S.: by the way: the scanner for the lexical analysis is much easier to implement (already done by hand) than a parser for xml, I think)
Mar 20 '07 #3
dorinbogdan
839 Expert 512MB
Hi,
Did you succeed to solve the problem ?
If yes, please let me know, in order to close the thread.
Thanks,
Dorin.
Mar 21 '07 #4

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

Similar topics

1
by: Karalius, Joseph | last post by:
Can anyone explain what is happening here? I haven't found any useful info on Google yet. Thanks in advance. mmagnet:/home/jkaralius/src/zopeplone/Python-2.3.5 # make gcc -pthread -c...
0
by: Chad Whitacre | last post by:
Hey all, I've been playing around with the parser module, and based on the documentation I would expect all symbols in a parse tree to be part of the grammar. For example, I find this line in...
2
by: Peter Rilling | last post by:
I am written a program that will be used to parse the lexical syntax of code files. I would like to generalize the grammar logic so that I don't hardcode any specific grammar in my program. ...
4
by: Matthew Bowman | last post by:
I'm in need of some assistance in converting an LL(2) grammar to an LL(1) grammar. I'm having difficulties with this. Note: this is for a school project and the grammar is not my choice. Thanks...
4
by: ben | last post by:
getting a bit confused with the details of how c's grammar is specified, especially when you get self-reference like in this: postfix-expression: primary-expression postfix-expression ...
14
by: Magius | last post by:
Hello, I have a question about the correctness of the language grammar for the C# 2.0 specification. I am working with the grammar specified in the June 2005 ECMA-334 standard. Basically, a...
2
by: Bhupesh Naik | last post by:
This is a query regarding my problem to make a spell and grammar check possible in text area of a web page. We have aspx pages which are used to construct letters. The browser based screens...
5
by: Remco van Engelen | last post by:
Hello, I have a question regarding the ISO C grammar. The syntax of a direct-declarator reads (section A.2.2, page 413 in my copy; the (R1) is just to 'name' the rule for later reference): ...
4
by: Paulo Matos | last post by:
Hi all, I'm trying to work out a parser for function declarations but it turns out that it is harder than I initially thought. I'm looking at 3rd Ed of Stroustrup, page 808. I'm trying to parse...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.