469,337 Members | 5,884 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,337 developers. It's quick & easy.

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 3222
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

Post your reply

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

Similar topics

reply views Thread by Chad Whitacre | last post: by
2 posts views Thread by Peter Rilling | last post: by
4 posts views Thread by Matthew Bowman | last post: by
14 posts views Thread by Magius | last post: by
5 posts views Thread by Remco van Engelen | last post: by
4 posts views Thread by Paulo Matos | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.