FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Enki XML parsing

 
Post new topic   Reply to topic     Forum Index -> DDL - D Dynamic Libraries
View previous topic :: View next topic  
Author Message
keinfarbton



Joined: 03 Dec 2005
Posts: 224
Location: Stuttgart - Germany

PostPosted: Wed Oct 04, 2006 6:40 pm    Post subject: Enki XML parsing Reply with quote

I try to use the xml parser, coming with enki.
It compiles/builds fine, and I applied the change to Expression.d 594 you showed in another thread.

I give this data to it
Code:
<?xml version="1.0" encoding="UTF-8"?>
<root></root>


I put some writefln in the BaseXMLParser, so the output is:
Code:
parsing
onStartDocument
onPI version="1.0" encoding="UTF-8"
onStartTag root
onEndTag root
onEndDocument
success


Now I change the text to:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<root>text</root>


Then I get this output with the following errors:
Code:
parsing
onStartDocument
onPI version="1.0" encoding="UTF-8"
onStartTag root
onPCData t
onPCData e
onPCData s
onPCData t/
onPCData r
onPCData o
onPCData o
onPCData t
onPCData >

Errors:
(6,2) Expected '</'
(6,2) Expected '<'
(6,2) Expected '&'
(6,2) Expected '&'
(6,2) Expected EntityRef or CharRef.
(6,2) Expected '<![CDATA['
(6,2) Expected '<?'
(6,2) Expected '<!--'
(6,2) Unexpected end-of-input
(6,2) Expected any.
(6,2) Expected element, Reference, CDSect, PI, Comment or PCData.
(6,2) Expected content.
(6,2) Expected BaseChar.
(6,2) Expected Ideographic.
(6,2) Expected '-'
(6,2) Expected Letter.
(6,2) Expected Name.


What did I do wrong?
Back to top
View user's profile Send private message
keinfarbton



Joined: 03 Dec 2005
Posts: 224
Location: Stuttgart - Germany

PostPosted: Wed Oct 04, 2006 6:54 pm    Post subject: Reply with quote

In the generated XMLParser.d line 944:
Code:
if((terminal("<").success) || (terminal("&").success)){

I think the if needs a inversion like this:
Code:
if(!((terminal("<").success) || (terminal("&").success))){

So it seams to work.
Back to top
View user's profile Send private message
keinfarbton



Joined: 03 Dec 2005
Posts: 224
Location: Stuttgart - Germany

PostPosted: Thu Oct 05, 2006 11:20 am    Post subject: Reply with quote

Okay, I think I understand now I bit more of the syntax:
The above means, please change XMLParser.bnf line 170 from
Code:
::= any:value {any:value} /!("<"|"&")

to
Code:
::= any:value {any:value} /("<"|"&")

by removing the "!"

I think in MiscName the "_" should be added?
Back to top
View user's profile Send private message
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Thu Oct 05, 2006 12:34 pm    Post subject: Reply with quote

Nice work with patching the grammar, and sorry for the mistake. I'll add this to the changes needed for 1.3. Smile

As for the MiscName definition, I think you're right. I double-checked the XML 1.0 spec and it has NameChar defined a little differently:

http://www.w3.org/TR/REC-xml/#NT-NameChar
Quote:

NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender


This is what I get for using a BNF extract from a questionable source. Feel free to use this variation if it helps - I'll likely be placing this in the library.
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DDL - D Dynamic Libraries All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group