XML/Input: Difference between revisions
m
→PEG-based Parsing: allow </foo >; def q(_):
m (→PEG-based Parsing: allow </foo >; def q(_):) |
|||
Line 2,024:
| .result = .result + [.match] ;
# consume the literal string $s
def q($s):
select(.remainder | startswith($s))
| .remainder |= .[$s | length :] ;
def literal($s):
| .result += [$s];
Line 2,066 ⟶ 2,067:
(consume("'") | parse("[^']*") | consume("'")));
def CDataSec : box("@CDATA";
def PROLOG : box("@PROLOG";
def DTD : box("@DTD";
# The XML spec specifically disallows double-hyphen within comments
def COMMENT : box("@COMMENT";
def CharData : parse("[^<]+"); # only `<` is disallowed
# This is more permissive than required:
def Name : parse("[A-Za-z:_][^/=<>\n\r\t ]*");
def Attribute : keyvalue(Name | ws |
def Attributes: box( plus(Attribute) ) | .result[-1] |= {"@attributes": add} ;
Line 2,081 ⟶ 2,084:
def Element :
def Content : star(Element // CDataSec // CharData // COMMENT);
objectify(
| Name
| .result[-1] as $name
| ws
| (Attributes // ws)
| ( (
// (
| ws) ) ;
|