- From: Steven Pemberton <steven.pemberton@cwi.nl>
- Date: Sun, 04 Sep 2022 12:15:21 +0000
- To: ixml <public-ixml@w3.org>
- Message-Id: <1662292453223.404958786.1357019619@cwi.nl>
I found a use for [ ]! Languages that use indentation for grouping are not context-free, but you can still parse them, just not in the general case (like the gedcom example recently, there's a limit to the nesting). In this sort of style: list: ( word, newline, list1?)+. list1: ( indent, word, newline, list2?)+. list2: ( indent, indent, word, newline, list3?)+. list3: ( indent, indent, indent, word, newline, list4?)+. list4: (indent, indent, indent, indent, word, newline )+. -indent: -" ". -newline: -#d?, -#a. word: [L]*. The problem with this is that if the nesting of the input is greater than what the grammar supports, you get an unhelpful message like: **** Parsing failed at line 13, position 17 oops ^ **** Character: " ". **** Permitted at this position: [L]*: [L] -#d?: #d newline: #a So what I did was change the definition of list4 to: list4: (indent, indent, indent, indent, word, newline, too-deeply-indented?)+. too-deeply-indented: indent, indent, indent, indent, indent, []. giving a slightly more helpful message: **** Parsing failed at line 13, position 21 oops ^ **** Character: "o". **** Permitted at this position: too-deeply-indented: [] Steven
Received on Sunday, 4 September 2022 12:15:45 UTC