Extended Backus-Naur Form - except-symbol

205 views
Skip to first unread message

Fabio Crisci

unread,
Jan 15, 2013, 10:17:34 AM1/15/13
to pe...@googlegroups.com
Hello,
I was trying to translate HTML specification into a PEG grammar. XML uses a simple EBNF notation

How would you translate the following?

CharData  // All text that is not markup constitutes the character data of the document.
  = [^<&]* - ([^<&]* "]]>" [^<&]*)

In other words I want to match an expression if it matches the first expression but not the second one.
Is it possible to do it in PEG or would it be a good idea to add the '-' symbol to PEG's grammar?

Thanks
Fabio

David Majda

unread,
Mar 12, 2013, 3:20:30 PM3/12/13
to piu...@gmail.com, pegjs
Hi,

2013/1/15 Fabio Crisci <piu...@gmail.com>:
Matching an expression that matches A but not B is already possible
today with predicates:

rule = !B A

I don't think additional special syntax is needed.

--
David Majda
Entropy fighter
http://majda.cz/
Reply all
Reply to author
Forward
0 new messages