Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the 'a' keyword in SPARQL lexer #1493

Merged
merged 3 commits into from May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/rouge/lexers/sparql.rb
Expand Up @@ -35,20 +35,21 @@ def self.keywords
state :root do
rule %r(\s+)m, Text::Whitespace
rule %r(#.*), Comment::Single

rule %r("""), Str::Double, :string_double_literal
rule %r("), Str::Double, :string_double
rule %r('''), Str::Single, :string_single_literal
rule %r('), Str::Single, :string_single

rule %r([$?]\w+), Name::Variable
rule %r((\w*:)(\w+)?) do |m|
token Name::Namespace, m[1]
token Str::Symbol, m[2]
end
rule %r(<[^>]*>), Name::Namespace
rule %r(true|false)i, Keyword::Constant

rule %r/a\b/, Keyword

rule %r([A-Z]\w+\b)i do |m|
if self.class.builtins.include? m[0].upcase
token Name::Builtin
Expand Down Expand Up @@ -101,7 +102,7 @@ def self.keywords
end
mixin :string_single_common
end

state :string_single_literal do
rule %r(''') do
token Str::Single
Expand Down
8 changes: 8 additions & 0 deletions spec/visual/samples/sparql
Expand Up @@ -52,3 +52,11 @@ false
'''The librarian said, "Perhaps you would enjoy 'War and Peace'."'''
"""The librarian said, 'Perhaps you would enjoy "War and Peace".'"""
"\u4444 and \U88888888"

# `a` keyword
PREFIX : <http://example.org/#>
SELECT ?item ?itemLabel
WHERE
{
?item a :Test .
}