Resolve elementdecl with RegExp

M

Max

Hello everyone!

I'm writing a simple xml parser with Javascript, but i have some problems
matching markupdecl because of elementdecl

markupdecl ::= elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI |
Comment

elementdecl is not a regular expression because of its circular procedure:

children ::= (choice | seq) ('?' | '*' | '+')?
cp ::= (Name | choice | seq) ('?' | '*' | '+')?
choice ::= '(' S? cp ( S? '|' S? cp )* S? ')'
seq ::= '(' S? cp ( S? ',' S? cp )* S? ')'

elementdecl -> contentspec -> children -> choice | seq -> cp -> choice | seq
etc.

Since elementdecl is not a regular expression, markupdecl cannot be either
:(

How to resolve the definitions of choice, seq and cp with regular
expression?

I have to match element without capture it.

Thanks,

Max
 
S

Soren Kuula

Max said:
Hello everyone!

I'm writing a simple xml parser with Javascript, but i have some problems
matching markupdecl because of elementdecl

markupdecl ::= elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI |
Comment

elementdecl is not a regular expression because of its circular procedure:

children ::= (choice | seq) ('?' | '*' | '+')?
cp ::= (Name | choice | seq) ('?' | '*' | '+')?
choice ::= '(' S? cp ( S? '|' S? cp )* S? ')'
seq ::= '(' S? cp ( S? ',' S? cp )* S? ')'

elementdecl -> contentspec -> children -> choice | seq -> cp -> choice | seq
etc.

Since elementdecl is not a regular expression, markupdecl cannot be either

Then you will have to give up having a token for element decls, and use
a nonterminal instead.

Make nonterminals for choice, seq etc too, since they are not regular
either.

BTW, I have made a javacc DTD parser. Mail me if you want it.

Søren
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,005
Messages
2,570,264
Members
46,859
Latest member
HeidiAtkin

Latest Threads

Top