Module: SPARQL::Grammar::Terminals

Included in:
Parser, Parser11
Defined in:
vendor/bundler/ruby/3.3.0/bundler/gems/sparql-796d3be4aa08/lib/sparql/grammar/terminals.rb

Constant Summary collapse

U_CHARS1 =

Unicode regular expressions for Ruby 1.9+ with the Oniguruma engine.

Regexp.compile(<<-EOS.gsub(/\s+/, ''))
  [\\u00C0-\\u00D6]|[\\u00D8-\\u00F6]|[\\u00F8-\\u02FF]|
  [\\u0370-\\u037D]|[\\u037F-\\u1FFF]|[\\u200C-\\u200D]|
  [\\u2070-\\u218F]|[\\u2C00-\\u2FEF]|[\\u3001-\\uD7FF]|
  [\\uF900-\\uFDCF]|[\\uFDF0-\\uFFFD]|[\\u{10000}-\\u{EFFFF}]
EOS
U_CHARS2 =
Regexp.compile("\\u00B7|[\\u0300-\\u036F]|[\\u203F-\\u2040]").freeze
IRI_RANGE =
Regexp.compile("[[^<>\"{}|^`\\\\]&&[^\\x00-\\x20]]").freeze
PERCENT =

170s

/%[0-9A-Fa-f]{2}/.freeze
PN_LOCAL_ESC =

172s

/\\[_~\.\-\!$\&'\(\)\*\+,;=:\/\?\#@%]/.freeze
PLX =

169s

/#{PERCENT}|#{PN_LOCAL_ESC}/.freeze
PN_CHARS_BASE =

153

/[A-Z]|[a-z]|#{U_CHARS1}/.freeze
PN_CHARS_U =

154

/_|#{PN_CHARS_BASE}/.freeze
VARNAME =

155

/(?:[0-9]|#{PN_CHARS_U})
(?:[0-9]|#{PN_CHARS_U}|#{U_CHARS2})*/x.freeze
PN_CHARS =

156

/-|[0-9]|#{PN_CHARS_U}|#{U_CHARS2}/.freeze
PN_LOCAL_BODY =
/(?:(?:\.|:|#{PN_CHARS}|#{PLX})*(?:#{PN_CHARS}|:|#{PLX}))?/.freeze
PN_CHARS_BODY =
/(?:(?:\.|#{PN_CHARS})*#{PN_CHARS})?/.freeze
PN_PREFIX =

157

/#{PN_CHARS_BASE}#{PN_CHARS_BODY}/.freeze
PN_LOCAL =

158

/(?:[0-9]|:|#{PN_CHARS_U}|#{PLX})#{PN_LOCAL_BODY}/.freeze
EXPONENT =

144

/[eE][+-]?[0-9]+/
ECHAR =

149

/\\[tbnrf\\"']/.freeze
IRIREF =

18

/<(?:#{IRI_RANGE})*>/.freeze
PNAME_NS =

129

/#{PN_PREFIX}?:/.freeze
PNAME_LN =

130

/(?:#{PNAME_NS})(?:#{PN_LOCAL})/.freeze
BLANK_NODE_LABEL =

131

/_:(?:[0-9]|#{PN_CHARS_U})((#{PN_CHARS}|\.)*#{PN_CHARS})?/.freeze
VAR1 =

132

/\?#{VARNAME}/.freeze
VAR2 =

133

/\$#{VARNAME}/.freeze
LANGTAG =

134

/@[a-zA-Z]+(?:-[a-zA-Z0-9]+)*/.freeze
LANG_DIR =
/@([a-zA-Z]+(?:-[a-zA-Z0-9]+)*(?:--[a-zA-Z]+)?)/u.freeze
INTEGER =

135

/[0-9]+/.freeze
DECIMAL =

136

/(?:[0-9]*\.[0-9]+)/.freeze
DOUBLE =

137

/(?:[0-9]+\.[0-9]*#{EXPONENT}|\.?[0-9]+#{EXPONENT})/.freeze
INTEGER_POSITIVE =

138

/(\+)([0-9]+)/.freeze
DECIMAL_POSITIVE =

139

/(\+)([0-9]*\.[0-9]+)/.freeze
DOUBLE_POSITIVE =

140

/(\+)([0-9]+\.[0-9]*#{EXPONENT}|\.?[0-9]+#{EXPONENT})/.freeze
INTEGER_NEGATIVE =

141

/(\-)([0-9]+)/.freeze
DECIMAL_NEGATIVE =

142

/(\-)([0-9]*\.[0-9]+)/.freeze
DOUBLE_NEGATIVE =

143

/(\-)([0-9]+\.[0-9]*#{EXPONENT}|\.?[0-9]+#{EXPONENT})/.freeze
STRING_LITERAL1 =

145

/'([^\'\\\n\r]|#{ECHAR})*'/.freeze
STRING_LITERAL2 =

146

/"([^\"\\\n\r]|#{ECHAR})*"/.freeze
STRING_LITERAL_LONG1 =

147

/'''((?:'|'')?(?:[^'\\]|#{ECHAR}))*'''/m.freeze
STRING_LITERAL_LONG2 =

148

/"""((?:"|"")?(?:[^"\\]|#{ECHAR}))*"""/m.freeze
WS =

151

/(?:\s|(?:#[^\n\r]*))+/m.freeze
NIL =

150

/\(#{WS}*\)/m.freeze
ANON =

152

/\[#{WS}*\]/m.freeze
STR_EXPR =

String terminals, case insensitive

%r(ABS|ADD|ADJUST|ALL|ASC|ASK|AS|AVG|BASE|BINDINGS|BIND
   |BNODE|BOUND|BY|CEIL|CLEAR|COALESCE|CONCAT
   |CONSTRUCT|CONTAINS|COPY|COUNT|CREATE|DATATYPE|DAY
   |DEFAULT|DELETE\s+DATA|DELETE\s+WHERE|DELETE
   |DESCRIBE|DESC|DISTINCT|DROP|ENCODE_FOR_URI|EXISTS
   |FILTER|FLOOR|FROM|GRAPH|GROUP_CONCAT|GROUP|HAVING
   |HOURS|IF|INSERT\s+DATA|INSERT|INTO|IN|IRI
   |LANGMATCHES|LANGTAG|LANG_DIR|LANG|LCASE|LIMIT|LOAD
   |MAX|MD5|MINUS|MINUTES|MIN|MONTH|MOVE
   |NAMED|NOT|NOW|OFFSET|OPTIONAL
   |ORDER|PREFIX|RAND|REDUCED|REGEX|REPLACE|ROUND|SAMPLE|SECONDS
   |SELECT|SEPARATOR|SERVICE
   |SHA1|SHA224|SHA256|SHA384|SHA512|SILENT
   |STRAFTER|STRBEFORE|STRDT|STRENDS|STRLANG|STRLEN|STRSTARTS|STRUUID|SUBSTR|STR|SUM
   |TIMEZONE|TO|TZ|UCASE|UNDEF|UNION|URI|USING|UUID|VALUES
   |WHERE|WITH|YEAR
   |isBLANK|isIRI|isURI|isLITERAL|isNUMERIC|sameTerm
   |isTRIPLE|TRIPLE|SUBJECT|PREDICATE|OBJECT
   |true
   |false
   |<<\(|\)>>
   |<<|>>
   |\{\||\|\}
   |~|&&|!=|!|<=|>=|\^\^|\|\||[\(\),.;\[\]\{\}\+\-=<>\?\^\|\*\/a]
)xim.freeze
STR_MAP =

Map terminals to canonical form

(%w{ABS ADD ADJUST ALL ASC ASK AS AVG BASE BINDINGS BIND
  BNODE BOUND BY CEIL CLEAR COALESCE CONCAT
  CONSTRUCT CONTAINS COPY COUNT CREATE DATATYPE DAY
  DEFAULT DELETE
  DESCRIBE DESC DISTINCT DROP ENCODE_FOR_URI EXISTS
  FILTER FLOOR FROM GRAPH GROUP_CONCAT GROUP HAVING
  HOURS IF INSERT INTO IN IRI
  LANGMATCHES LANGTAG LANG_DIR LANG LCASE LIMIT LOAD
  MAX MD5 MINUS MINUTES MIN MONTH MOVE
  NAMED NOT NOW OFFSET OPTIONAL
  ORDER PREFIX RAND REDUCED REGEX REPLACE ROUND SAMPLE SECONDS
  SELECT SEPARATOR SERVICE
  SHA1 SHA224 SHA256 SHA384 SHA512 SILENT
  STRAFTER STRBEFORE STRDT STRENDS STRLANG STRLEN STRSTARTS STRUUID SUBSTR STR SUM
  TIMEZONE TO TZ UCASE UNDEF UNION URI USING UUID
  VALUES WHERE WITH YEAR
  isBLANK isIRI isURI isLITERAL isNUMERIC sameTerm
  isTRIPLE TRIPLE SUBJECT PREDICATE OBJECT
  true false
} + [
  "DELETE DATA",
  "DELETE WHERE",
  "INSERT DATA",
]).inject({}) {|memo, t| memo[t.downcase] = t; memo}.freeze