From 863cc89e80c896231e4f6b570e7146fda05b7b96 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Sat, 10 Jun 2023 13:41:05 -0700 Subject: [PATCH 1/5] Use wider range of escapes for showing character escapes in HTML. --- etc/ebnf.html | 65 +- etc/ebnf.ll1.rb | 2 +- etc/ebnf.peg.rb | 2 +- etc/sparql.html | 3028 +++++++++++++++++++++----------------------- etc/turtle.html | 188 ++- lib/ebnf/writer.rb | 148 ++- 6 files changed, 1659 insertions(+), 1774 deletions(-) diff --git a/etc/ebnf.html b/etc/ebnf.html index da753ae..0888c91 100644 --- a/etc/ebnf.html +++ b/etc/ebnf.html @@ -1,17 +1,17 @@ - + - + - + @@ -29,40 +29,41 @@ - + - + - + - + - + - + - - + + + @@ -70,85 +71,71 @@ - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - + + + diff --git a/etc/ebnf.ll1.rb b/etc/ebnf.ll1.rb index 8e40933..ffde156 100644 --- a/etc/ebnf.ll1.rb +++ b/etc/ebnf.ll1.rb @@ -1,4 +1,4 @@ -# This file is automatically generated by ebnf version 2.1.2 +# This file is automatically generated by ebnf version 2.3.4 # Derived from etc/ebnf.ebnf module Meta START = :ebnf diff --git a/etc/ebnf.peg.rb b/etc/ebnf.peg.rb index 617ba15..a0f4e73 100644 --- a/etc/ebnf.peg.rb +++ b/etc/ebnf.peg.rb @@ -1,4 +1,4 @@ -# This file is automatically generated by ebnf version 2.1.2 +# This file is automatically generated by ebnf version 2.3.4 # Derived from etc/ebnf.ebnf module EBNFMeta RULES = [ diff --git a/etc/sparql.html b/etc/sparql.html index 5df8a80..bae9802 100644 --- a/etc/sparql.html +++ b/etc/sparql.html @@ -1,1605 +1,1425 @@ -
[1] ebnf ::=( declaration | rule) * (declaration | rule)*
[2] declaration ::="@terminals" | pass"@terminals" | pass
[3][5] alt ::=seq ( "|" seq) * seq ("|" seq)*
[6] seq ::=diff+ diff+
[7] diff ::=postfix ( "-" postfix) ? postfix ("-" postfix)?
[8] postfix ::=primary POSTFIX? primary POSTFIX?
[9] primary ::=HEX | SYMBOL | O_RANGE | RANGE | STRING1 | STRING2 | ( "(" expression ")") HEX | SYMBOL | O_RANGE | RANGE | STRING1 | STRING2 | ("(" expression ")")
[10] pass ::="@pass" expression"@pass" expression
@terminals
@terminals # Productions for terminals
[11] LHS ::=( "[" SYMBOL "]" #x20+ ) ? SYMBOL #x20* "::="("[" SYMBOL "]" #x20+)? SYMBOL #x20* "::="
[12] SYMBOL ::=( [ a-z] | [ A-Z] | [ 0-9] | "_" | ".") + ([a-z] | [A-Z] | [0-9] | "_" | ".")+
[13] HEX ::="#x" ( [ a-f] | [ A-F] | [ 0-9] ) + "#x" ([a-f] | [A-F] | [0-9])+
[14] RANGE ::="[" ( ( R_CHAR "-" R_CHAR) | ( HEX "-" HEX) | R_CHAR | HEX) + "-"? ( "]" - LHS) "[" ((R_CHAR "-" R_CHAR) | (HEX "-" HEX) | R_CHAR | HEX)+ "-"? ("]" - LHS)
[15] O_RANGE ::="[^" ( ( R_CHAR "-" R_CHAR) | ( HEX "-" HEX) | R_CHAR | HEX) + "-"? "]""[^" ((R_CHAR "-" R_CHAR) | (HEX "-" HEX) | R_CHAR | HEX)+ "-"? "]"
[16] STRING1 ::='"' ( CHAR - '"') * '"''"' (CHAR - '"')* '"'
[17] STRING2 ::="'" ( CHAR - "'") * "'""'" (CHAR - "'")* "'"
[18] CHAR ::=[ #x09#x0A#x0D] | [ #x20-#xD7FF] | [ #xE000-#xFFFD] | [ #x00010000-#x0010FFFF] [#x09#x0A#x0D] | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x00010000-#x0010FFFF]
[19] R_CHAR ::=CHAR - ( "]" | "-" | HEX) CHAR - ("]" | "-" | HEX)
[20] POSTFIX ::=[ ?*+] [?*+]
[21] PASS ::=[ #x09#x0A#x0D#x20][#x09#x0A#x0D#x20] | ((("#" - "#x") | "//") [^#x0A#x0D]*) | ("/*" (("*" [^/])? | [^*])* "*/") | ("(*" (("*" [^)])? | [^*])* "*)")
|( ( ( "#" - "#x") | "//") [ ^#x0A#x0D] * )
|( "/*" ( ( "*" [ ^/] ) ? | [ ^*] ) * "*/")
|( "(*" ( ( "*" [ ^)] ) ? | [ ^*] ) * "*)")
@pass
@pass PASS
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
[1]QueryUnit::= -Query? -
[2]Query::= -Prologue -(SelectQuery | ConstructQuery | DescribeQuery | AskQuery) -
[3]UpdateUnit::= -Update -
[4]Prologue::= -(BaseDecl | PrefixDecl)* -
[5]BaseDecl::= -"BASE" IRIREF -
[6]PrefixDecl::= -"PREFIX" PNAME_NS IRIREF -
[7]SelectQuery::= -SelectClause -DatasetClause* -WhereClause -SolutionModifier -ValuesClause -
[8]SubSelect::= -SelectClause -WhereClause -SolutionModifier -ValuesClause -
[9]SelectClause::= -"SELECT" -("DISTINCT" | "REDUCED")? -((Var | "(" Expression "AS" Var ")")+ | "*") -
[10]ConstructQuery::= -"CONSTRUCT" -(ConstructTemplate DatasetClause* WhereClause SolutionModifier | DatasetClause* "WHERE" "{" TriplesTemplate? "}" SolutionModifier) -ValuesClause -
[11]DescribeQuery::= -"DESCRIBE" -(VarOrIri+ | "*") -DatasetClause* -WhereClause? -SolutionModifier -ValuesClause -
[12]AskQuery::= -"ASK" DatasetClause* WhereClause ValuesClause -
[13]DatasetClause::= -"FROM" (DefaultGraphClause | NamedGraphClause) -
[14]DefaultGraphClause::= -SourceSelector -
[15]NamedGraphClause::= -"NAMED" SourceSelector -
[16]SourceSelector::= -iri -
[17]WhereClause::= -"WHERE"? GroupGraphPattern -
[18]SolutionModifier::= -GroupClause? -HavingClause? -OrderClause? -LimitOffsetClauses? -
[19]GroupClause::= -"GROUP" "BY" GroupCondition+ -
[20]GroupCondition::= -BuiltInCall -| FunctionCall -| "(" Expression ("AS" Var)? ")" -| Var -
[21]HavingClause::= -"HAVING" HavingCondition+ -
[22]HavingCondition::= -Constraint -
[23]OrderClause::= -"ORDER" "BY" OrderCondition+ -
[24]OrderCondition::= -("ASC" | "DESC") BrackettedExpression -| Constraint | Var -
[25]LimitOffsetClauses::= -LimitClause OffsetClause? -| OffsetClause LimitClause? -
[26]LimitClause::= -"LIMIT" INTEGER -
[27]OffsetClause::= -"OFFSET" INTEGER -
[28]ValuesClause::= -("VALUES" DataBlock)? -
[29]Update::= -Prologue (Update1 (";" Update)?)? -
[30]Update1::= -Load -| Clear -| Drop -| Add -| Move -| Copy -| Create -| InsertData -| DeleteData -| DeleteWhere -| Modify -
[31]Load::= -"LOAD" "SILENT"? iri ("INTO" GraphRef)? -
[32]Clear::= -"CLEAR" "SILENT"? GraphRefAll -
[33]Drop::= -"DROP" "SILENT"? GraphRefAll -
[34]Create::= -"CREATE" "SILENT"? GraphRef -
[35]Add::= -"ADD" -"SILENT"? -GraphOrDefault -"TO" -GraphOrDefault -
[36]Move::= -"MOVE" -"SILENT"? -GraphOrDefault -"TO" -GraphOrDefault -
[37]Copy::= -"COPY" -"SILENT"? -GraphOrDefault -"TO" -GraphOrDefault -
[38]InsertData::= -"INSERT DATA" QuadData -
[39]DeleteData::= -"DELETE DATA" QuadData -
[40]DeleteWhere::= -"DELETE WHERE" QuadPattern -
[41]Modify::= -("WITH" iri)? -(DeleteClause InsertClause? | InsertClause) -UsingClause* -"WHERE" -GroupGraphPattern -
[42]DeleteClause::= -"DELETE" QuadPattern -
[43]InsertClause::= -"INSERT" QuadPattern -
[44]UsingClause::= -"USING" (iri | "NAMED" iri) -
[45]GraphOrDefault::= -"DEFAULT" | "GRAPH"? iri -
[46]GraphRef::= -"GRAPH" iri -
[47]GraphRefAll::= -GraphRef | "DEFAULT" | "NAMED" | "ALL" -
[48]QuadPattern::= -"{" Quads "}" -
[49]QuadData::= -"{" Quads "}" -
[50]Quads::= -TriplesTemplate? -(QuadsNotTriples "."? TriplesTemplate?)* -
[51]QuadsNotTriples::= -"GRAPH" VarOrIri "{" TriplesTemplate? "}" -
[52]TriplesTemplate::= -TriplesSameSubject ("." TriplesTemplate?)? -
[53]GroupGraphPattern::= -"{" (SubSelect | GroupGraphPatternSub) "}" -
[54]GroupGraphPatternSub::= -TriplesBlock? -(GraphPatternNotTriples "."? TriplesBlock?)* -
[55]TriplesBlock::= -TriplesSameSubjectPath ("." TriplesBlock?)? -
[56]GraphPatternNotTriples::= -GroupOrUnionGraphPattern -| OptionalGraphPattern -| MinusGraphPattern -| GraphGraphPattern -| ServiceGraphPattern -| Filter -| Bind -| InlineData -
[57]OptionalGraphPattern::= -"OPTIONAL" GroupGraphPattern -
[58]GraphGraphPattern::= -"GRAPH" VarOrIri GroupGraphPattern -
[59]ServiceGraphPattern::= -"SERVICE" "SILENT"? VarOrIri GroupGraphPattern -
[60]Bind::= -"BIND" "(" Expression "AS" Var ")" -
[61]InlineData::= -"VALUES" DataBlock -
[62]DataBlock::= -InlineDataOneVar | InlineDataFull -
[63]InlineDataOneVar::= -Var "{" DataBlockValue* "}" -
[64]InlineDataFull::= -(NIL | "(" Var* ")") -"{" -("(" DataBlockValue* ")" | NIL)* -"}" -
[65]DataBlockValue::= -iri -| RDFLiteral -| NumericLiteral -| BooleanLiteral -| "UNDEF" -
[66]MinusGraphPattern::= -"MINUS" GroupGraphPattern -
[67]GroupOrUnionGraphPattern::= -GroupGraphPattern ("UNION" GroupGraphPattern)* -
[68]Filter::= -"FILTER" Constraint -
[69]Constraint::= -BrackettedExpression -| BuiltInCall -| FunctionCall -
[70]FunctionCall::= -iri ArgList -
[71]ArgList::= -NIL -| "(" "DISTINCT"? Expression ("," Expression)* ")" -
[72]ExpressionList::= -NIL | "(" Expression ("," Expression)* ")" -
[73]ConstructTemplate::= -"{" ConstructTriples? "}" -
[74]ConstructTriples::= -TriplesSameSubject ("." ConstructTriples?)? -
[75]TriplesSameSubject::= -VarOrTerm PropertyListNotEmpty -| TriplesNode PropertyList -
[76]PropertyList::= -PropertyListNotEmpty? -
[77]PropertyListNotEmpty::= -Verb ObjectList (";" (Verb ObjectList)?)* -
[78]Verb::= -VarOrIri | "a" -
[79]ObjectList::= -Object ("," Object)* -
[80]Object::= -GraphNode -
[81]TriplesSameSubjectPath::= -VarOrTerm PropertyListNotEmptyPath -| TriplesNode PropertyListPath -
[82]PropertyListPath::= -PropertyListNotEmpty? -
[83]PropertyListNotEmptyPath::= -(VerbPath | VerbSimple) -ObjectList -(";" (VerbPath | VerbSimple) ObjectList?)* -
[84]VerbPath::= -Path -
[85]VerbSimple::= -Var -
[86]ObjectListPath::= -ObjectPath ("," ObjectPath)* -
[87]ObjectPath::= -GraphNodePath -
[88]Path::= -PathAlternative -
[89]PathAlternative::= -PathSequence ("|" PathSequence)* -
[90]PathSequence::= -PathEltOrInverse ("/" PathEltOrInverse)* -
[91]PathElt::= -PathPrimary PathMod? -
[92]PathEltOrInverse::= -PathElt | "^" PathElt -
[93]PathMod::= -"*" -| "?" -| "+" -| "{" (Integer ("," ("}" | Integer "}") | "}") | "," Integer "}") -
[94]PathPrimary::= -iri -| "a" -| #x21 PathNegatedPropertySet -| "(" Path ")" -
[95]PathNegatedPropertySet::= -PathOneInPropertySet -| "(" (PathOneInPropertySet ("|" PathOneInPropertySet)*)? ")" -
[96]PathOneInPropertySet::= -iri | "a" | "^" (iri | "a") -
[97]Integer::= -INTEGER -
[98]TriplesNode::= -Collection | BlankNodePropertyList -
[99]BlankNodePropertyList::= -"[" PropertyListNotEmpty "]" -
[100]TriplesNodePath::= -CollectionPath | BlankNodePropertyListPath -
[101]BlankNodePropertyListPath::= -"[" PropertyListPathNotEmpty "]" -
[102]Collection::= -"(" GraphNode+ ")" -
[103]CollectionPath::= -"(" GraphNodePath+ ")" -
[104]GraphNode::= -VarOrTerm | TriplesNode -
[105]GraphNodePath::= -VarOrTerm | TriplesNodePath -
[106]VarOrTerm::= -Var | GraphTerm -
[107]VarOrIri::= -Var | iri -
[108]Var::= -VAR1 | VAR2 -
[109]GraphTerm::= -iri -| RDFLiteral -| NumericLiteral -| BooleanLiteral -| BlankNode -| NIL -
[110]Expression::= -ConditionalOrExpression -
[111]ConditionalOrExpression::= -ConditionalAndExpression -("||" ConditionalAndExpression)* -
[112]ConditionalAndExpression::= -ValueLogical ("&&" ValueLogical)* -
[113]ValueLogical::= -RelationalExpression -
[114]RelationalExpression::= -NumericExpression -("=" NumericExpression | "!=" NumericExpression | "<" NumericExpression | ">" NumericExpression | "<=" NumericExpression | ">=" NumericExpression | "IN" ExpressionList | "NOT" "IN" ExpressionList)? -
[115]NumericExpression::= -AdditiveExpression -
[116]AdditiveExpression::= -MultiplicativeExpression -("+" MultiplicativeExpression | "-" MultiplicativeExpression | (NumericLiteralPositive | NumericLiteralNegative) ("*" UnaryExpression | "/" UnaryExpression)?)* -
[117]MultiplicativeExpression::= -UnaryExpression -("*" UnaryExpression | "/" UnaryExpression)* -
[118]UnaryExpression::= -#x21 PrimaryExpression -| "+" PrimaryExpression -| "-" PrimaryExpression -| PrimaryExpression -
[119]PrimaryExpression::= -BrackettedExpression -| BuiltInCall -| iriOrFunction -| RDFLiteral -| NumericLiteral -| BooleanLiteral -| Var -
[120]BrackettedExpression::= -"(" Expression ")" -
[121]BuiltInCall::= -Aggregate -| "STR" "(" Expression ")" -| "LANG" "(" Expression ")" -| "LANGMATCHES" "(" Expression "," Expression ")" -| "DATATYPE" "(" Expression ")" -| "BOUND" "(" Var ")" -| "IRI" "(" Expression ")" -| "URI" "(" Expression ")" -| "BNODE" ("(" Expression ")" | NIL) -| "RAND" NIL -| "ABS" "(" Expression ")" -| "CEIL" "(" Expression ")" -| "FLOOR" "(" Expression ")" -| "ROUND" "(" Expression ")" -| "CONCAT" ExpressionList -| SubstringExpression -| "STRLEN" "(" Expression ")" -| StrReplaceExpression -| "UCASE" "(" Expression ")" -| "LCASE" "(" Expression ")" -| "ENCODE_FOR_URI" "(" Expression ")" -| "CONTAINS" "(" Expression "," Expression ")" -| "STRSTARTS" "(" Expression "," Expression ")" -| "STRENDS" "(" Expression "," Expression ")" -| "STRBEFORE" "(" Expression "," Expression ")" -| "STRAFTER" "(" Expression "," Expression ")" -| "YEAR" "(" Expression ")" -| "MONTH" "(" Expression ")" -| "DAY" "(" Expression ")" -| "HOURS" "(" Expression ")" -| "MINUTES" "(" Expression ")" -| "SECONDS" "(" Expression ")" -| "TIMEZONE" "(" Expression ")" -| "TZ" "(" Expression ")" -| "NOW" NIL -| "UUID" NIL -| "STRUUID" NIL -| "MD5" "(" Expression ")" -| "SHA1" "(" Expression ")" -| "SHA224" "(" Expression ")" -| "SHA256" "(" Expression ")" -| "SHA384" "(" Expression ")" -| "SHA512" "(" Expression ")" -| "COALESCE" ExpressionList -| "IF" "(" Expression "," Expression "," Expression ")" -| "STRLANG" "(" Expression "," Expression ")" -| "STRDT" "(" Expression "," Expression ")" -| "sameTerm" "(" Expression "," Expression ")" -| "isIRI" "(" Expression ")" -| "isURI" "(" Expression ")" -| "isBLANK" "(" Expression ")" -| "isLITERAL" "(" Expression ")" -| "isNUMERIC" "(" Expression ")" -| RegexExpression -| ExistsFunc -| NotExistsFunc -
[122]RegexExpression::= -"REGEX" -"(" -Expression -"," -Expression -("," Expression)? -")" -
[123]SubstringExpression::= -"SUBSTR" -"(" -Expression -"," -Expression -("," Expression)? -")" -
[124]StrReplaceExpression::= -"REPLACE" -"(" -Expression -"," -Expression -"," -Expression -("," Expression)? -")" -
[125]ExistsFunc::= -"EXISTS" GroupGraphPattern -
[126]NotExistsFunc::= -"NOT" "EXISTS" GroupGraphPattern -
[127]Aggregate::= -"COUNT" "(" "DISTINCT"? ("*" | Expression) ")" -| "SUM" "(" "DISTINCT"? Expression ")" -| "MIN" "(" "DISTINCT"? Expression ")" -| "MAX" "(" "DISTINCT"? Expression ")" -| "AVG" "(" "DISTINCT"? Expression ")" -| "SAMPLE" "(" "DISTINCT"? Expression ")" -| "GROUP_CONCAT" "(" "DISTINCT"? Expression (";" "SEPARATOR" "=" String)? ")" -
[128]iriOrFunction::= -iri ArgList? -
[129]RDFLiteral::= -String (LANGTAG | "^^" iri)? -
[130]NumericLiteral::= -NumericLiteralUnsigned -| NumericLiteralPositive -| NumericLiteralNegative -
[131]NumericLiteralUnsigned::= -INTEGER | DECIMAL | DOUBLE -
[132]NumericLiteralPositive::= -INTEGER_POSITIVE -| DECIMAL_POSITIVE -| DOUBLE_POSITIVE -
[133]NumericLiteralNegative::= -INTEGER_NEGATIVE -| DECIMAL_NEGATIVE -| DOUBLE_NEGATIVE -
[134]BooleanLiteral::= -"true" | "false" -
[135]String::= -STRING_LITERAL1 -| STRING_LITERAL2 -| STRING_LITERAL_LONG1 -| STRING_LITERAL_LONG2 -
[136]iri::= -IRIREF | PrefixedName -
[137]PrefixedName::= -PNAME_LN | PNAME_NS -
[138]BlankNode::= -BLANK_NODE_LABEL | ANON -
[139]IRIREF::= -"<" -[^#x00-#x20<>"{}|^`]#x20|#x20UCHAR)*#x20'>'] -
[140]PNAME_NS::= -PN_PREFIX? ":" -
[141]PNAME_LN::= -PNAME_NS PN_LOCAL -
[142]BLANK_NODE_LABEL::= -"_:" -(PN_CHARS_U | [0-9]) -(PN_CHARS | ".")* PN_CHARS? -
[143]VAR1::= -"?" VARNAME -
[144]VAR2::= -"$" VARNAME -
[145]LANGTAG::= -"@" ([a-zA-Z])+ ("-" ([a-zA-Z0-9])+)* -
[146]INTEGER::= -([0-9])+ -
[147]DECIMAL::= -([0-9])* "." ([0-9])+ -
[148]DOUBLE::= -([0-9])+ "." ([0-9])* EXPONENT -| "." ([0-9])+ EXPONENT -| ([0-9])+ EXPONENT -
[149]INTEGER_POSITIVE::= -"+" INTEGER -
[150]DECIMAL_POSITIVE::= -"+" DECIMAL -
[151]DOUBLE_POSITIVE::= -"+" DOUBLE -
[152]INTEGER_NEGATIVE::= -"-" INTEGER -
[153]DECIMAL_NEGATIVE::= -"-" DECIMAL -
[154]DOUBLE_NEGATIVE::= -"-" DOUBLE -
[155]EXPONENT::= -[eE] ([+-])? ([0-9])+ -
[156]STRING_LITERAL1::= -"'" ([^#x27#x5C#xA#xD] | ECHAR)* "'" -
[157]STRING_LITERAL2::= -'"' ([^#x22#x5C#xA#xD] | ECHAR)* '"' -
[158]STRING_LITERAL_LONG1::= -"'''" -(("'" | "''")? [^']#x20|#x20ECHAR#x20)#x20)*#x20"'''"]) -
[159]STRING_LITERAL_LONG2::= -'"""' -(('"' | '""')? [^"]#x20|#x20ECHAR#x20)#x20)*#x20'"""']) -
[160]ECHAR::= -"\" [tbnrf"'] -
[161]NIL::= -"(" WS* ")" -
[162]WS::= -#x20 | #x9 | #xD | #xA -
[163]ANON::= -"[" WS* "]" -
[164]PN_CHARS_BASE::= -[A-Z] -| [a-z] -| [#x00C0-#x00D6] -| [#x00D8-#x00F6] -| [#x00F8-#x02FF] -| [#x0370-#x037D] -| [#x037F-#x1FFF] -| [#x200C-#x200D] -| [#x2070-#x218F] -| [#x2C00-#x2FEF] -| [#x3001-#xD7FF] -| [#xF900-#xFDCF] -| [#xFDF0-#xFFFD] -| [#x10000-#xEFFFF] -
[165]PN_CHARS_U::= -PN_CHARS_BASE | "_" -
[166]VARNAME::= -(PN_CHARS_U | [0-9]) -(PN_CHARS_U | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040])* -
[167]PN_CHARS::= -PN_CHARS_U -| "-" -| [0-9] -| #x00B7 -| [#x0300-#x036F] -| [#x203F-#x2040] -
[168]PN_PREFIX::= -PN_CHARS_BASE (PN_CHARS | ".")* PN_CHARS? -
[169]PN_LOCAL::= -(PN_CHARS_U | [0-9]) -(PN_CHARS | ".")* PN_CHARS? -
[170]PLX::= -PERCENT | PN_LOCAL_ESC -
[171]PERCENT::= -"%" HEX HEX -
[172]HEX::= -[0-9] | [A-F] | [a-f] -
[173]PN_LOCAL_ESC::= -"\" -("_" | "~" | "." | "-" | #x21 | "$" | "&" | "'" | "(" | ")" | "*" | "+" | "," | ";" | "=" | "/" | "?" | "#" | "@" | "%") -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[1]QueryUnit::=Query?
[2]Query::=Prologue (SelectQuery | ConstructQuery | DescribeQuery | AskQuery)
[3]UpdateUnit::=Update
[4]Prologue::=(BaseDecl | PrefixDecl)*
[5]BaseDecl::="BASE" IRIREF
[6]PrefixDecl::="PREFIX" PNAME_NS IRIREF
[7]SelectQuery::=SelectClause DatasetClause* WhereClause SolutionModifier ValuesClause
[8]SubSelect::=SelectClause WhereClause SolutionModifier ValuesClause
[9]SelectClause::="SELECT" ("DISTINCT" | "REDUCED")? ((Var | ("(" Expression "AS" Var ")"))+ | "*")
[10]ConstructQuery::="CONSTRUCT" ((ConstructTemplate DatasetClause* WhereClause SolutionModifier) | (DatasetClause* "WHERE" "{" TriplesTemplate? "}" SolutionModifier)) ValuesClause
[11]DescribeQuery::="DESCRIBE" (VarOrIri+ | "*") DatasetClause* WhereClause? SolutionModifier ValuesClause
[12]AskQuery::="ASK" DatasetClause* WhereClause ValuesClause
[13]DatasetClause::="FROM" (DefaultGraphClause | NamedGraphClause)
[14]DefaultGraphClause::=SourceSelector
[15]NamedGraphClause::="NAMED" SourceSelector
[16]SourceSelector::=iri
[17]WhereClause::="WHERE"? GroupGraphPattern
[18]SolutionModifier::=GroupClause? HavingClause? OrderClause? LimitOffsetClauses?
[19]GroupClause::="GROUP" "BY" GroupCondition+
[20]GroupCondition::=BuiltInCall | FunctionCall | ("(" Expression ("AS" Var)? ")") | Var
[21]HavingClause::="HAVING" HavingCondition+
[22]HavingCondition::=Constraint
[23]OrderClause::="ORDER" "BY" OrderCondition+
[24]OrderCondition::=(("ASC" | "DESC") BrackettedExpression) | (Constraint | Var)
[25]LimitOffsetClauses::=(LimitClause OffsetClause?) | (OffsetClause LimitClause?)
[26]LimitClause::="LIMIT" INTEGER
[27]OffsetClause::="OFFSET" INTEGER
[28]ValuesClause::=("VALUES" DataBlock)?
[29]Update::=Prologue (Update1 (";" Update)?)?
[30]Update1::=Load | Clear | Drop | Add | Move | Copy | Create | InsertData | DeleteData | DeleteWhere | Modify
[31]Load::="LOAD" "SILENT"? iri ("INTO" GraphRef)?
[32]Clear::="CLEAR" "SILENT"? GraphRefAll
[33]Drop::="DROP" "SILENT"? GraphRefAll
[34]Create::="CREATE" "SILENT"? GraphRef
[35]Add::="ADD" "SILENT"? GraphOrDefault "TO" GraphOrDefault
[36]Move::="MOVE" "SILENT"? GraphOrDefault "TO" GraphOrDefault
[37]Copy::="COPY" "SILENT"? GraphOrDefault "TO" GraphOrDefault
[38]InsertData::="INSERT DATA" QuadData
[39]DeleteData::="DELETE DATA" QuadData
[40]DeleteWhere::="DELETE WHERE" QuadPattern
[41]Modify::=("WITH" iri)? ((DeleteClause InsertClause?) | InsertClause) UsingClause* "WHERE" GroupGraphPattern
[42]DeleteClause::="DELETE" QuadPattern
[43]InsertClause::="INSERT" QuadPattern
[44]UsingClause::="USING" (iri | ("NAMED" iri))
[45]GraphOrDefault::="DEFAULT" | ("GRAPH"? iri)
[46]GraphRef::="GRAPH" iri
[47]GraphRefAll::=GraphRef | "DEFAULT" | "NAMED" | "ALL"
[48]QuadPattern::="{" Quads "}"
[49]QuadData::="{" Quads "}"
[50]Quads::=TriplesTemplate? (QuadsNotTriples "."? TriplesTemplate?)*
[51]QuadsNotTriples::="GRAPH" VarOrIri "{" TriplesTemplate? "}"
[52]TriplesTemplate::=TriplesSameSubject ("." TriplesTemplate?)?
[53]GroupGraphPattern::="{" (SubSelect | GroupGraphPatternSub) "}"
[54]GroupGraphPatternSub::=TriplesBlock? (GraphPatternNotTriples "."? TriplesBlock?)*
[55]TriplesBlock::=TriplesSameSubjectPath ("." TriplesBlock?)?
[56]GraphPatternNotTriples::=GroupOrUnionGraphPattern | OptionalGraphPattern | MinusGraphPattern | GraphGraphPattern | ServiceGraphPattern | Filter | Bind | InlineData
[57]OptionalGraphPattern::="OPTIONAL" GroupGraphPattern
[58]GraphGraphPattern::="GRAPH" VarOrIri GroupGraphPattern
[59]ServiceGraphPattern::="SERVICE" "SILENT"? VarOrIri GroupGraphPattern
[60]Bind::="BIND" "(" Expression "AS" Var ")"
[61]InlineData::="VALUES" DataBlock
[62]DataBlock::=InlineDataOneVar | InlineDataFull
[63]InlineDataOneVar::=Var "{" DataBlockValue* "}"
[64]InlineDataFull::=(NIL | ("(" Var* ")")) "{" (("(" DataBlockValue* ")") | NIL)* "}"
[65]DataBlockValue::=iri | RDFLiteral | NumericLiteral | BooleanLiteral | "UNDEF"
[66]MinusGraphPattern::="MINUS" GroupGraphPattern
[67]GroupOrUnionGraphPattern::=GroupGraphPattern ("UNION" GroupGraphPattern)*
[68]Filter::="FILTER" Constraint
[69]Constraint::=BrackettedExpression | BuiltInCall | FunctionCall
[70]FunctionCall::=iri ArgList
[71]ArgList::=NIL | ("(" "DISTINCT"? Expression ("," Expression)* ")")
[72]ExpressionList::=NIL | ("(" Expression ("," Expression)* ")")
[73]ConstructTemplate::="{" ConstructTriples? "}"
[74]ConstructTriples::=TriplesSameSubject ("." ConstructTriples?)?
[75]TriplesSameSubject::=(VarOrTerm PropertyListNotEmpty) | (TriplesNode PropertyList)
[76]PropertyList::=PropertyListNotEmpty?
[77]PropertyListNotEmpty::=Verb ObjectList (";" (Verb ObjectList)?)*
[78]Verb::=VarOrIri | "a"
[79]ObjectList::=Object ("," Object)*
[80]Object::=GraphNode
[81]TriplesSameSubjectPath::=(VarOrTerm PropertyListNotEmptyPath) | (TriplesNode PropertyListPath)
[82]PropertyListPath::=PropertyListNotEmpty?
[83]PropertyListNotEmptyPath::=(VerbPath | VerbSimple) ObjectList (";" ((VerbPath | VerbSimple) ObjectList)?)*
[84]VerbPath::=Path
[85]VerbSimple::=Var
[86]ObjectListPath::=ObjectPath ("," ObjectPath)*
[87]ObjectPath::=GraphNodePath
[88]Path::=PathAlternative
[89]PathAlternative::=PathSequence ("|" PathSequence)*
[90]PathSequence::=PathEltOrInverse ("/" PathEltOrInverse)*
[91]PathElt::=PathPrimary PathMod?
[92]PathEltOrInverse::=PathElt | ("^" PathElt)
[93]PathMod::="*" | "?" | "+" | ("{" ((Integer (("," ("}" | (Integer "}"))) | "}")) | ("," Integer "}")))
[94]PathPrimary::=iri | "a" | ("!" PathNegatedPropertySet) | ("(" Path ")")
[95]PathNegatedPropertySet::=PathOneInPropertySet | ("(" (PathOneInPropertySet ("|" PathOneInPropertySet)*)? ")")
[96]PathOneInPropertySet::=iri | "a" | ("^" (iri | "a"))
[97]Integer::=INTEGER
[98]TriplesNode::=Collection | BlankNodePropertyList
[99]BlankNodePropertyList::="[" PropertyListNotEmpty "]"
[100]TriplesNodePath::=CollectionPath | BlankNodePropertyListPath
[101]BlankNodePropertyListPath::="[" PropertyListPathNotEmpty "]"
[102]Collection::="(" GraphNode+ ")"
[103]CollectionPath::="(" GraphNodePath+ ")"
[104]GraphNode::=VarOrTerm | TriplesNode
[105]GraphNodePath::=VarOrTerm | TriplesNodePath
[106]VarOrTerm::=Var | GraphTerm
[107]VarOrIri::=Var | iri
[108]Var::=VAR1 | VAR2
[109]GraphTerm::=iri | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | NIL
[110]Expression::=ConditionalOrExpression
[111]ConditionalOrExpression::=ConditionalAndExpression ("||" ConditionalAndExpression)*
[112]ConditionalAndExpression::=ValueLogical ("&&" ValueLogical)*
[113]ValueLogical::=RelationalExpression
[114]RelationalExpression::=NumericExpression
(("=" NumericExpression)("!=" NumericExpression) | ("<" NumericExpression) | (">" NumericExpression) | ("<=" NumericExpression) | (">=" NumericExpression) | ("IN" ExpressionList) | ("NOT" "IN" ExpressionList))?
[115]NumericExpression::=AdditiveExpression
[116]AdditiveExpression::=MultiplicativeExpression
(("+" MultiplicativeExpression)("-" MultiplicativeExpression) | ((NumericLiteralPositive | NumericLiteralNegative) (("*" UnaryExpression) | ("/" UnaryExpression))?))*
[117]MultiplicativeExpression::=UnaryExpression (("*" UnaryExpression) | ("/" UnaryExpression))*
[118]UnaryExpression::=("!" PrimaryExpression) | ("+" PrimaryExpression) | ("-" PrimaryExpression) | PrimaryExpression
[119]PrimaryExpression::=BrackettedExpression | BuiltInCall | iriOrFunction | RDFLiteral | NumericLiteral | BooleanLiteral | Var
[120]BrackettedExpression::="(" Expression ")"
[121]BuiltInCall::=Aggregate
|("STR" "(" Expression ")")
|("LANG" "(" Expression ")")
|("LANGMATCHES" "(" Expression "," Expression ")")
|("DATATYPE" "(" Expression ")")
|("BOUND" "(" Var ")")
|("IRI" "(" Expression ")")
|("URI" "(" Expression ")")
|("BNODE" (("(" Expression ")") | NIL))
|("RAND" NIL)
|("ABS" "(" Expression ")")
|("CEIL" "(" Expression ")")
|("FLOOR" "(" Expression ")")
|("ROUND" "(" Expression ")")
|("CONCAT" ExpressionList)
|SubstringExpression
|("STRLEN" "(" Expression ")")
|StrReplaceExpression
|("UCASE" "(" Expression ")")
|("LCASE" "(" Expression ")")
|("ENCODE_FOR_URI" "(" Expression ")")
|("CONTAINS" "(" Expression "," Expression ")")
|("STRSTARTS" "(" Expression "," Expression ")")
|("STRENDS" "(" Expression "," Expression ")")
|("STRBEFORE" "(" Expression "," Expression ")")
|("STRAFTER" "(" Expression "," Expression ")")
|("YEAR" "(" Expression ")")
|("MONTH" "(" Expression ")")
|("DAY" "(" Expression ")")
|("HOURS" "(" Expression ")")
|("MINUTES" "(" Expression ")")
|("SECONDS" "(" Expression ")")
|("TIMEZONE" "(" Expression ")")
|("TZ" "(" Expression ")")
|("NOW" NIL)
|("UUID" NIL)
|("STRUUID" NIL)
|("MD5" "(" Expression ")")
|("SHA1" "(" Expression ")")
|("SHA224" "(" Expression ")")
|("SHA256" "(" Expression ")")
|("SHA384" "(" Expression ")")
|("SHA512" "(" Expression ")")
|("COALESCE" ExpressionList)
|("IF" "(" Expression "," Expression "," Expression ")")
|("STRLANG" "(" Expression "," Expression ")")
|("STRDT" "(" Expression "," Expression ")")
|("sameTerm" "(" Expression "," Expression ")")
|("isIRI" "(" Expression ")")
|("isURI" "(" Expression ")")
|("isBLANK" "(" Expression ")")
|("isLITERAL" "(" Expression ")")
|("isNUMERIC" "(" Expression ")")
|RegexExpression
|ExistsFunc
|NotExistsFunc
[122]RegexExpression::="REGEX" "(" Expression "," Expression ("," Expression)? ")"
[123]SubstringExpression::="SUBSTR" "(" Expression "," Expression ("," Expression)? ")"
[124]StrReplaceExpression::="REPLACE" "(" Expression "," Expression "," Expression ("," Expression)? ")"
[125]ExistsFunc::="EXISTS" GroupGraphPattern
[126]NotExistsFunc::="NOT" "EXISTS" GroupGraphPattern
[127]Aggregate::=("COUNT" "(" "DISTINCT"? ("*"Expression) ")")
|("SUM" "(" "DISTINCT"? Expression ")")
|("MIN" "(" "DISTINCT"? Expression ")")
|("MAX" "(" "DISTINCT"? Expression ")")
|("AVG" "(" "DISTINCT"? Expression ")")
|("SAMPLE" "(" "DISTINCT"? Expression ")")
|("GROUP_CONCAT" "(" "DISTINCT"? Expression (";" "SEPARATOR" "=" String)? ")")
[128]iriOrFunction::=iri ArgList?
[129]RDFLiteral::=String (LANGTAG | ("^^" iri))?
[130]NumericLiteral::=NumericLiteralUnsigned | NumericLiteralPositive | NumericLiteralNegative
[131]NumericLiteralUnsigned::=INTEGER | DECIMAL | DOUBLE
[132]NumericLiteralPositive::=INTEGER_POSITIVE | DECIMAL_POSITIVE | DOUBLE_POSITIVE
[133]NumericLiteralNegative::=INTEGER_NEGATIVE | DECIMAL_NEGATIVE | DOUBLE_NEGATIVE
[134]BooleanLiteral::="true" | "false"
[135]String::=STRING_LITERAL1 | STRING_LITERAL2 | STRING_LITERAL_LONG1 | STRING_LITERAL_LONG2
[136]iri::=IRIREF | PrefixedName
[137]PrefixedName::=PNAME_LN | PNAME_NS
[138]BlankNode::=BLANK_NODE_LABEL | ANON
@terminals# Productions for terminals
[139]IRIREF::="<" ([^<>"{}|^`\] - [#x00-#x20])* ">"
[140]PNAME_NS::=PN_PREFIX? ":"
[141]PNAME_LN::=PNAME_NS PN_LOCAL
[142]BLANK_NODE_LABEL::="_:" (PN_CHARS_U | [0-9]) ((PN_CHARS | ".")* PN_CHARS)?
[143]VAR1::="?" VARNAME
[144]VAR2::="$" VARNAME
[145]LANGTAG::="@" [a-zA-Z]+ ("-" [a-zA-Z0-9]+)*
[146]INTEGER::=[0-9]+
[147]DECIMAL::=[0-9]* "." [0-9]+
[148]DOUBLE::=([0-9]+ "." [0-9]* EXPONENT) | ("." [0-9]+ EXPONENT) | ([0-9]+ EXPONENT)
[149]INTEGER_POSITIVE::="+" INTEGER
[150]DECIMAL_POSITIVE::="+" DECIMAL
[151]DOUBLE_POSITIVE::="+" DOUBLE
[152]INTEGER_NEGATIVE::="-" INTEGER
[153]DECIMAL_NEGATIVE::="-" DECIMAL
[154]DOUBLE_NEGATIVE::="-" DOUBLE
[155]EXPONENT::=[eE] [+-]? [0-9]+
[156]STRING_LITERAL1::="'" ([^#x27#x5C#x0A#x0D] | ECHAR)* "'"
[157]STRING_LITERAL2::='"' ([^#x22#x5C#x0A#x0D] | ECHAR)* '"'
[158]STRING_LITERAL_LONG1::="'''" (("'" | "''")? ([^'\] | ECHAR))* "'''"
[159]STRING_LITERAL_LONG2::='"""' (('"' | '""')? ([^"\] | ECHAR))* '"""'
[160]ECHAR::="\" [tbnrf"']
[161]NIL::="(" WS* ")"
[162]WS::=#x20 | #x09 | #x0D | #x0A
[163]ANON::="[" WS* "]"
[164]PN_CHARS_BASE::=[A-Za-z]
|[#xC0-#xD6]
|[#xD8-#xF6]
|[#xF8-#x02FF]
|[#x0370-#x037D]
|[#x037F-#x1FFF]
|[#x200C-#x200D]
|[#x2070-#x218F]
|[#x2C00-#x2FEF]
|[#x3001-#xD7FF]
|[#xF900-#xFDCF]
|[#xFDF0-#xFFFD]
|[#x00010000-#x000EFFFF]
[165]PN_CHARS_U::=PN_CHARS_BASE | "_"
[166]VARNAME::=(PN_CHARS_U | [0-9]) (PN_CHARS_U | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040])*
[167]PN_CHARS::=PN_CHARS_U | "-" | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
[168]PN_PREFIX::=PN_CHARS_BASE ((PN_CHARS | ".")* PN_CHARS)?
[169]PN_LOCAL::=(PN_CHARS_U | [0-9]) ((PN_CHARS | ".")* PN_CHARS)?
[170]PLX::=PERCENT | PN_LOCAL_ESC
[171]PERCENT::="%" HEX HEX
[172]HEX::=[0-9A-Fa-f]
[173]PN_LOCAL_ESC::="\" ("_" | "~" | "." | "-" | "!" | "$" | "&" | "'" | "(" | ")" | "*" | "+" | "," | ";" | "=" | "/" | "?" | "#" | "@" | "%")
+ diff --git a/etc/turtle.html b/etc/turtle.html index 4d4bf5b..c32821a 100644 --- a/etc/turtle.html +++ b/etc/turtle.html @@ -1,229 +1,273 @@ - - + - + + - + + - + + - + + - + + - + + - + + - + + - + + - + + - + + - + + - + + - + + - + + - + + - + + - + + - + + - + + - + + - + + - + + - + + + - + + - + + - + + - + + - + + - + + - + + - + + - + + - + + - + - + + - + - + + - + + - + + - + + - + + - + + - + + - + + + @@ -235,100 +279,108 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + + - + + - + - + + - + + - + + - + + - + + - + + diff --git a/lib/ebnf/writer.rb b/lib/ebnf/writer.rb index b5ab6b8..2f8b229 100644 --- a/lib/ebnf/writer.rb +++ b/lib/ebnf/writer.rb @@ -11,42 +11,81 @@ class Writer LINE_LENGTH = 80 LINE_LENGTH_HTML = 200 - # ASCII escape names - ASCII_ESCAPE_NAMES = [ - "null", #x00 - "start of heading", #x01 - "start of text", #x02 - "end of text", #x03 - "end of transmission", #x04 - "enquiry", #x05 - "acknowledge", #x06 - "bell", #x07 - "backspace", #x08 - "horizontal tab", #x09 - "new line", #x0A - "vertical tab", #x0B - "form feed", #x0C - "carriage return", #x0D - "shift out", #x0E - "shift in", #x0F - "data link escape", #x10 - "device control 1", #x11 - "device control 2", #x12 - "device control 3", #x13 - "device control 4", #x14 - "negative acknowledge", #x15 - "synchronous idle", #x16 - "end of trans. block", #x17 - "cancel", #x18 - "end of medium", #x19 - "substitute", #x1A - "escape", #x1B - "file separator", #x1C - "group separator", #x1D - "record separator", #x1E - "unit separator", #x1F - "space" #x20 - ] + # UNICODE escape names + # From https://en.wikipedia.org/wiki/List_of_Unicode_characters + UNICODE_ESCAPE_NAMES = { + 0x00 => 'null', + 0x01 => 'start of heading', + 0x02 => 'start of text', + 0x03 => 'end of text', + 0x04 => 'end of transmission', + 0x05 => 'enquiry', + 0x06 => 'acknowledge', + 0x07 => 'bell', + 0x08 => 'backspace', + 0x09 => 'horizontal tab', + 0x0A => 'new line', + 0x0B => 'vertical tab', + 0x0C => 'form feed', + 0x0D => 'carriage return', + 0x0E => 'shift out', + 0x0F => 'shift in', + 0x10 => 'data link escape', + 0x11 => 'device control 1', + 0x12 => 'device control 2', + 0x13 => 'device control 3', + 0x14 => 'device control 4', + 0x15 => 'negative acknowledge', + 0x16 => 'synchronous idle', + 0x17 => 'end of trans. block', + 0x18 => 'cancel', + 0x19 => 'end of medium', + 0x1A => 'substitute', + 0x1B => 'escape', + 0x1C => 'file separator', + 0x1D => 'group separator', + 0x1E => 'record separator', + 0x1F => 'unit separator', + 0x20 => 'space', + 0x22 => 'dquote', + 0x27 => 'apos', + 0x2F => 'slash', + 0x5C => 'back slash', + 0x60 => 'grave', + 0x7F => 'delete', + 0x80 => 'padding character', + 0x81 => 'high octet preset', + 0x82 => 'break permitted here', + 0x83 => 'no break here', + 0x84 => 'index', + 0x85 => 'next line', + 0x86 => 'start of selected area', + 0x87 => 'end of selected area', + 0x88 => 'character tabulation set', + 0x89 => 'character tabulation with justification', + 0x8A => 'line tabulation set', + 0x8B => 'partial line forward', + 0x8C => 'partial line backward', + 0x8D => 'reverse line feed', + 0x8E => 'single-shift two', + 0x8F => 'single-shift three', + 0x90 => 'device control string', + 0x91 => 'private use 1', + 0x92 => 'private use 2', + 0x93 => 'set transmit state', + 0x94 => 'cancel character', + 0x95 => 'message waiting', + 0x96 => 'start of protected area', + 0x97 => 'end of protected area', + 0x98 => 'start of string', + 0x99 => 'single graphic character introducer', + 0x9A => 'single character intro introducer', + 0x9B => 'control sequence introducer', + 0x9C => 'string terminator', + 0x9D => 'operating system command', + 0x9E => 'private message', + 0x9F => 'application program command', + } ## # Format rules to a String @@ -360,27 +399,19 @@ def format_ebnf_string(string, quote = '"') def escape_ebnf_hex(u) fmt = case u.ord - when 0x00..0x20 then "#x%02X" when 0x0000..0x00ff then "#x%02X" when 0x0100..0xffff then "#x%04X" else "#x%08X" end char = fmt % u.ord if @options[:html] - char = if u.ord <= 0x20 - %(#{@coder.encode char}) - elsif u.ord == 0x22 - %(>") - elsif u.ord < 0x7F - %(#{@coder.encode char}) - elsif u.ord == 0x7F - %(#{@coder.encode char}) - elsif u.ord <= 0xFF - %(#{char}) - elsif (%w(Control Private-use Surrogate Noncharacter Reserved) - ::Unicode::Types.of(u)).empty? - %(#{char}) + char = if UNICODE_ESCAPE_NAMES.include?(u.ord) + %(#{char}) + elsif ([::Unicode::Types.of(u)] - %w(Control Private-use Surrogate Noncharacter Reserved)).empty? + %(#{char}) else - %(#{char}) + uni_esc = "U+%04X" % u.ord + %(#{char}) end %(#{char}) else @@ -561,18 +592,13 @@ def escape_abnf_hex(u) end char = "%x" + (fmt % u.ord).upcase if @options[:html] - if u.ord <= 0x20 - char = %(#{@coder.encode char}) - elsif u.ord == 0x22 - %(>") - elsif u.ord < 0x7F - char = %(#{@coder.encode char}) - elsif u.ord == 0x7F - char = %(#{@coder.encode char}) - elsif u.ord <= 0xFF - char = %(#{char}) + char = if UNICODE_ESCAPE_NAMES.include?(u.ord) + %(#{char}) + elsif ([::Unicode::Types.of(u)] - %w(Control Private-use Surrogate Noncharacter Reserved)).empty? + %(#{char}) else - char = %(#{char}) + uni_esc = "U+%04X" % u.ord + %(#{char}) end %(#{char}) else From 9a581383ae5cd2384811bdd298d850f6d57382cb Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Mon, 12 Jun 2023 12:55:17 -0700 Subject: [PATCH 2/5] Use solidus/reverse solidus for range descriptions, instead of slash/backslash. --- lib/ebnf/writer.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ebnf/writer.rb b/lib/ebnf/writer.rb index 2f8b229..f3b85e9 100644 --- a/lib/ebnf/writer.rb +++ b/lib/ebnf/writer.rb @@ -49,8 +49,8 @@ class Writer 0x20 => 'space', 0x22 => 'dquote', 0x27 => 'apos', - 0x2F => 'slash', - 0x5C => 'back slash', + 0x2F => 'solidus', + 0x5C => 'reverse solidus', 0x60 => 'grave', 0x7F => 'delete', 0x80 => 'padding character', From 2c210cdcfa13af1a702a5abb98b31418c72cfbf3 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Mon, 12 Jun 2023 13:07:59 -0700 Subject: [PATCH 3/5] Revert "Use solidus/reverse solidus for range descriptions, instead of slash/backslash." This reverts commit 9a581383ae5cd2384811bdd298d850f6d57382cb. --- lib/ebnf/writer.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ebnf/writer.rb b/lib/ebnf/writer.rb index f3b85e9..2f8b229 100644 --- a/lib/ebnf/writer.rb +++ b/lib/ebnf/writer.rb @@ -49,8 +49,8 @@ class Writer 0x20 => 'space', 0x22 => 'dquote', 0x27 => 'apos', - 0x2F => 'solidus', - 0x5C => 'reverse solidus', + 0x2F => 'slash', + 0x5C => 'back slash', 0x60 => 'grave', 0x7F => 'delete', 0x80 => 'padding character', From cb84726cc68ca1e3225d8f90ea9e1c397b811a84 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Mon, 12 Jun 2023 13:08:36 -0700 Subject: [PATCH 4/5] Back to "slash" and "backslash". --- lib/ebnf/writer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ebnf/writer.rb b/lib/ebnf/writer.rb index 2f8b229..f6bdcfd 100644 --- a/lib/ebnf/writer.rb +++ b/lib/ebnf/writer.rb @@ -50,7 +50,7 @@ class Writer 0x22 => 'dquote', 0x27 => 'apos', 0x2F => 'slash', - 0x5C => 'back slash', + 0x5C => 'backslash', 0x60 => 'grave', 0x7F => 'delete', 0x80 => 'padding character', From 17ebcbdd5b6773b27c229042e8bdbf698db3e15d Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Mon, 17 Jul 2023 13:33:08 -0700 Subject: [PATCH 5/5] Version 2.3.5. --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 3f684d2..cc6c9a4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.3.4 +2.3.5
[1]turtleDoc ::= statement*
[2]statement ::= directive | (triples ".")
[3]directive ::= prefixID | base | sparqlPrefix | sparqlBase
[4]prefixID ::= "@prefix" PNAME_NS IRIREF "."
[5]base ::= "@base" IRIREF "."
[28s]sparqlPrefix ::= SPARQL_PREFIX PNAME_NS IRIREF
[29s]sparqlBase ::= SPARQL_BASE IRIREF
[6]triples ::= (subject predicateObjectList) | (blankNodePropertyList predicateObjectList?)
[7]predicateObjectList ::= verb objectList (";" (verb objectList)?)*
[8]objectList ::= object ("," object)*
[9]verb ::= predicate | "a"
[10]subject ::= iri | BlankNode | collection
[11]predicate ::= iri
[12]object ::= iri | BlankNode | collection | blankNodePropertyList | literal
[13]literal ::= RDFLiteral | NumericLiteral | BooleanLiteral
[14]blankNodePropertyList ::= "[" predicateObjectList "]"
[15]collection ::= "(" object* ")"
[16]NumericLiteral ::= INTEGER | DECIMAL | DOUBLE
[128s]RDFLiteral ::= String (LANGTAG | ("^^" iri))?
[133s]BooleanLiteral ::= "true" | "false"
[17]String ::= STRING_LITERAL_QUOTE | STRING_LITERAL_SINGLE_QUOTE | STRING_LITERAL_LONG_SINGLE_QUOTE | STRING_LITERAL_LONG_QUOTE
[135s]iri ::= IRIREF | PrefixedName
[136s]PrefixedName ::= PNAME_LN | PNAME_NS
[137s]BlankNode ::= BLANK_NODE_LABEL | ANON
@terminals # Productions for terminals
[18]IRIREF ::= "<" (([^<>"{}|^`\] - [#x00-#x20]) | UCHAR)* ">"
[139s]PNAME_NS ::= PN_PREFIX? ":"
[140s]PNAME_LN ::= PNAME_NS PN_LOCAL
[141s]BLANK_NODE_LABEL ::= "_:" (PN_CHARS_U | [0-9]) ((PN_CHARS | ".")* PN_CHARS)?
[144s]LANGTAG ::= "@" [a-zA-Z]+ ("-" [a-zA-Z0-9]+)*
[19]INTEGER ::= [+-]? [0-9]+
[20]DECIMAL ::= [+-]? ([0-9]* "." [0-9]+)
[21]DOUBLE ::= [+-]? (([0-9]+ "." [0-9]* EXPONENT) | ("." [0-9]+ EXPONENT) | ([0-9]+ EXPONENT))
[154s]EXPONENT ::= [eE] [+-]? [0-9]+
[22]STRING_LITERAL_QUOTE ::='"' ([^>"#x5C#x0A#x0D] | ECHAR | UCHAR)* '"''"' ([^#x22#x5C#x0A#x0D] | ECHAR | UCHAR)* '"'
[23]STRING_LITERAL_SINGLE_QUOTE ::="'" ([^#x27#x5C#x0A#x0D] | ECHAR | UCHAR)* "'""'" ([^#x27#x5C#x0A#x0D] | ECHAR | UCHAR)* "'"
[24]STRING_LITERAL_LONG_SINGLE_QUOTE ::= "'''" (("'" | "''")? ([^'\] | ECHAR | UCHAR))* "'''"
[25]STRING_LITERAL_LONG_QUOTE ::= '"""' (('"' | '""')? ([^"\] | ECHAR | UCHAR))* '"""'
[26]UCHAR ::= ("u" HEX HEX HEX HEX) | ("U" HEX HEX HEX HEX HEX HEX HEX HEX)
[159s]ECHAR ::= "\" [tbnrf"']
[28t]SPARQL_PREFIX ::= [Pp] [Rr] [Ee] [Ff] [Ii] [Xx]
[29t]SPARQL_BASE ::= [Bb] [Aa] [Ss] [Ee]
[161s]WS ::= #x20 | #x09 | #x0D | #x0A
[162s]ANON ::= "[" WS* "]"
[163s]PN_CHARS_BASE ::= [A-Z]
|[#xC0-#xD6][#xC0-#xD6]
|[#xD8-#xF6][#xD8-#xF6]
|[#xF8-#x02FF][#xF8-#x02FF]
|[#x0370-#x037D][#x0370-#x037D]
|[#x037F-#x1FFF][#x037F-#x1FFF]
|[#x200C-#x200D][#x200C-#x200D]
|[#x2070-#x218F][#x2070-#x218F]
|[#x2C00-#x2FEF][#x2C00-#x2FEF]
|[#x3001-#xD7FF][#x3001-#xD7FF]
|[#xF900-#xFDCF][#xF900-#xFDCF]
|[#xFDF0-#xFFFD][#xFDF0-#xFFFD]
|[#x00010000-#x000EFFFF][#x00010000-#x000EFFFF]
[164s]PN_CHARS_U ::= PN_CHARS_BASE | "_"
[166s]PN_CHARS ::=PN_CHARS_U | "-" | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]PN_CHARS_U | "-" | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
[167s]PN_PREFIX ::= PN_CHARS_BASE ((PN_CHARS | ".")* PN_CHARS)?
[168s]PN_LOCAL ::= (PN_CHARS_U | ":" | [0-9] | PLX) ((PN_CHARS | "." | ":" | PLX)* (PN_CHARS | ":" | PLX))?
[169s]PLX ::= PERCENT | PN_LOCAL_ESC
[170s]PERCENT ::= "%" HEX HEX
[171s]HEX ::= [0-9A-Fa-f]
[172s]PN_LOCAL_ESC ::= "\" ("_" | "~" | "." | "-" | "!" | "$" | "&" | "'" | "(" | ")" | "*" | "+" | "," | ";" | "=" | "/" | "?" | "#" | "@" | "%")