Skip to content

Commit

Permalink
Add string literals E".." and L".." to control entity expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhkay committed Oct 15, 2023
1 parent 0e26cd8 commit 13168c7
Show file tree
Hide file tree
Showing 3 changed files with 353 additions and 181 deletions.
167 changes: 130 additions & 37 deletions specifications/grammar-40/xpath-grammar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4370,43 +4370,136 @@ ErrorVal ::= "$" VarName

<g:token name="StringLiteral" inline="false" value-type="string"
whitespace-spec="explicit" delimiter-type="delimiting">
<g:choice name="StringDilimitType">
<g:sequence>
<g:string>"</g:string>
<g:zeroOrMore name="CharsInQuote">
<g:choice name="QuoteTypeChar">
<g:ref name="PredefinedEntityRef" if="xquery40"/>
<g:ref name="CharRef" if="xquery40" token-user-action="checkCharRef(token.image);"/>
<g:ref name="EscapeQuot" />
<g:complement>
<g:charClass>
<g:char>"</g:char>
<g:char if="xquery40">&amp;</g:char>
</g:charClass>
</g:complement>
</g:choice>
</g:zeroOrMore>
<g:string>"</g:string>
</g:sequence>
<g:sequence>
<g:string>'</g:string>
<g:zeroOrMore name="CharsInApos">
<g:choice name="AposTypeChar">
<g:ref name="PredefinedEntityRef" if="xquery40"/>
<g:ref name="CharRef" if="xquery40" token-user-action="checkCharRef(token.image);"/>
<g:ref name="EscapeApos" />
<g:complement>
<g:charClass>
<g:char>'</g:char>
<g:char if="xquery40">&amp;</g:char>
</g:charClass>
</g:complement>
</g:choice>
</g:zeroOrMore>
<g:string>'</g:string>
</g:sequence>
<g:choice>
<g:ref name="AposStringLiteral"/>
<g:ref name="QuotStringLiteral"/>
<g:ref name="AposStringLiteralExpand"/>
<g:ref name="QuotStringLiteralExpand"/>
<g:ref name="AposStringLiteralNoExpand"/>
<g:ref name="QuotStringLiteralNoExpand"/>
</g:choice>
</g:token>

<g:token name="AposStringLiteral" inline="false" value-type="string"
whitespace-spec="explicit" delimiter-type="delimiting">
<g:sequence>
<g:string>'</g:string>
<g:zeroOrMore>
<g:choice>
<g:ref name="PredefinedEntityRef" if="xquery40"/>
<g:ref name="CharRef" if="xquery40" token-user-action="checkCharRef(token.image);"/>
<g:ref name="EscapeApos" />
<g:complement>
<g:charClass>
<g:char>'</g:char>
<g:char if="xquery40">&amp;</g:char>
</g:charClass>
</g:complement>
</g:choice>
</g:zeroOrMore>
<g:string>'</g:string>
</g:sequence>
</g:token>

<g:token name="AposStringLiteralExpand" inline="false" value-type="string"
whitespace-spec="explicit" delimiter-type="delimiting">
<g:sequence>
<g:string>E'</g:string>
<g:zeroOrMore>
<g:choice>
<g:ref name="PredefinedEntityRef"/>
<g:ref name="CharRef" token-user-action="checkCharRef(token.image);"/>
<g:ref name="EscapeApos" />
<g:complement>
<g:charClass>
<g:char>'</g:char>
<g:char>&amp;</g:char>
</g:charClass>
</g:complement>
</g:choice>
</g:zeroOrMore>
<g:string>'</g:string>
</g:sequence>
</g:token>

<g:token name="AposStringLiteralNoExpand" inline="false" value-type="string"
whitespace-spec="explicit" delimiter-type="delimiting">
<g:sequence>
<g:string>L'</g:string>
<g:zeroOrMore>
<g:choice>
<g:ref name="EscapeApos" />
<g:complement>
<g:charClass>
<g:char>'</g:char>
</g:charClass>
</g:complement>
</g:choice>
</g:zeroOrMore>
<g:string>'</g:string>
</g:sequence>
</g:token>

<g:token name="QuotStringLiteral" inline="false" value-type="string"
whitespace-spec="explicit" delimiter-type="delimiting">
<g:sequence>
<g:string>"</g:string>
<g:zeroOrMore>
<g:choice>
<g:ref name="PredefinedEntityRef" if="xquery40"/>
<g:ref name="CharRef" if="xquery40" token-user-action="checkCharRef(token.image);"/>
<g:ref name="EscapeQuot" />
<g:complement>
<g:charClass>
<g:char>"</g:char>
<g:char if="xquery40">&amp;</g:char>
</g:charClass>
</g:complement>
</g:choice>
</g:zeroOrMore>
<g:string>"</g:string>
</g:sequence>
</g:token>

<g:token name="QuotStringLiteralExpand" inline="false" value-type="string"
whitespace-spec="explicit" delimiter-type="delimiting">
<g:sequence>
<g:string>E"</g:string>
<g:zeroOrMore>
<g:choice>
<g:ref name="PredefinedEntityRef"/>
<g:ref name="CharRef" token-user-action="checkCharRef(token.image);"/>
<g:ref name="EscapeQuot" />
<g:complement>
<g:charClass>
<g:char>"</g:char>
<g:char if="xquery40">&amp;</g:char>
</g:charClass>
</g:complement>
</g:choice>
</g:zeroOrMore>
<g:string>"</g:string>
</g:sequence>
</g:token>

<g:token name="QuotStringLiteralNoExpand" inline="false" value-type="string"
whitespace-spec="explicit" delimiter-type="delimiting">
<g:sequence>
<g:string>L"</g:string>
<g:zeroOrMore>
<g:choice>
<g:ref name="EscapeQuot" />
<g:complement>
<g:charClass>
<g:char>"</g:char>
</g:charClass>
</g:complement>
</g:choice>
</g:zeroOrMore>
<g:string>"</g:string>
</g:sequence>
</g:token>


<g:token name="URIQualifiedName" inline="false" whitespace-spec="explicit" if="xpath40 xquery40 xslt40-patterns">
<g:ref name="BracedURILiteral"/>
Expand All @@ -4432,7 +4525,7 @@ ErrorVal ::= "$" VarName
<g:string>}</g:string>
</g:token>

<g:token name="PredefinedEntityRef" if="xquery40" inline="false" whitespace-spec="explicit" delimiter-type="hide">
<g:token name="PredefinedEntityRef" inline="false" whitespace-spec="explicit" delimiter-type="hide">
<g:string>&amp;</g:string>
<g:choice name="PredefinedEntityNames">
<g:string>lt</g:string>
Expand Down Expand Up @@ -4490,7 +4583,7 @@ ErrorVal ::= "$" VarName
<g:ref name="NCNameTok"/>
</g:token>

<g:token name="CharRef" if="xquery40" inline="false" is-xml="yes" xhref="http://www.w3.org/TR/REC-xml#NT-CharRef" xgc-id="xml-version" delimiter-type="hide">
<g:token name="CharRef" inline="false" is-xml="yes" xhref="http://www.w3.org/TR/REC-xml#NT-CharRef" xgc-id="xml-version" delimiter-type="hide">
<g:string>&amp;#</g:string>
<g:choice name="CharRefChars">
<g:ref name="Digits"/>
Expand Down
2 changes: 1 addition & 1 deletion specifications/xquery-40/src/errors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@
def="dt-expanded-qname">expanded QNames</termref>).</p>
</error>

<error spec="XQ" role="xquery" code="0090" class="ST" type="static">
<error spec="XQ" code="0090" class="ST" type="static">
<p> It is a <termref def="dt-static-error">static error</termref> if a <termref
def="dt-character-reference">character reference</termref> does not identify a valid
character in the version of XML that is in use.</p>
Expand Down
Loading

0 comments on commit 13168c7

Please sign in to comment.