Skip to content

Commit

Permalink
Change Text tokens for whitespace to Text::Whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximeKjaer committed Jun 14, 2019
1 parent 9384abb commit 02b524d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
56 changes: 28 additions & 28 deletions lib/rouge/lexers/xpath.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,36 +105,36 @@ def self.constructorTypes

# Functions
rule /(function)(\s*)(#{XPath.openParen})/ do # function declaration
groups Keyword, Text, Punctuation
groups Keyword, Text::Whitespace, Punctuation
end
rule /(map|array|empty-sequence)/, Keyword # constructors
rule /(#{XPath.kindTest})(\s*)(#{XPath.openParen})/ do # kindtest
push :kindtest
groups Keyword, Text, Punctuation
groups Keyword, Text::Whitespace, Punctuation
end
rule /(#{XPath.kindTestForPi})(\s*)(#{XPath.openParen})/ do # processing instruction kindtest
push :kindtestforpi
groups Keyword, Text, Punctuation
groups Keyword, Text::Whitespace, Punctuation
end
rule /(#{XPath.eqName})(\s*)(#{XPath.openParen})/ do # function call
groups Name::Function, Text, Punctuation
groups Name::Function, Text::Whitespace, Punctuation
end
rule /(#{XPath.eqName})(\s*)(#)(\s*)(\d+)/ do # namedFunctionRef
groups Name::Function, Text, Name::Function, Text, Name::Function
groups Name::Function, Text::Whitespace, Name::Function, Text::Whitespace, Name::Function
end

# Type commands
rule /(cast|castable)(\s+)(as)/ do
goto :singletype
groups Keyword, Text, Keyword
groups Keyword, Text::Whitespace, Keyword
end
rule /(treat)(\s+)(as)/ do
goto :itemtype
groups Keyword, Text, Keyword
groups Keyword, Text::Whitespace, Keyword
end
rule /(instance)(\s+)(of)/ do
goto :itemtype
groups Keyword, Text, Keyword
groups Keyword, Text::Whitespace, Keyword
end
rule /\b(as)\b/ do
token Keyword
Expand All @@ -144,24 +144,24 @@ def self.constructorTypes
# Paths
rule /\.\.|\.|\*/, Operator
rule /(#{XPath.ncName})(\s*)(:)(\s*)(\*)/ do
groups Name::Tag, Text, Punctuation, Text, Keyword::Reserved
groups Name::Tag, Text::Whitespace, Punctuation, Text::Whitespace, Keyword::Reserved
end
rule /(\*)(\s*)(:)(\s*)(#{XPath.ncName})/ do
groups Keyword::Reserved, Text, Punctuation, Text, Name::Tag
groups Keyword::Reserved, Text::Whitespace, Punctuation, Text::Whitespace, Name::Tag
end
rule /(#{XPath.axes})(\s*)(::)/ do
groups Keyword, Text, Operator
groups Keyword, Text::Whitespace, Operator
end
rule /@/, Name::Attribute, :attrname
rule XPath.eqName, Name::Tag

# Whitespace
rule /(\s+)/m, Text
rule /(\s+)/m, Text::Whitespace
end

state :singletype do
# Whitespace and comments
rule /\s+/m, Text
rule /\s+/m, Text::Whitespace
rule XPath.commentStart, Comment, :comment

# Type name
Expand All @@ -173,41 +173,41 @@ def self.constructorTypes

state :itemtype do
# Whitespace and comments
rule /\s+/m, Text
rule /\s+/m, Text::Whitespace
rule XPath.commentStart, Comment, :comment

# Type tests
rule /(#{XPath.kindTest})(\s*)(#{XPath.openParen})/ do
groups Keyword::Type, Text, Punctuation
groups Keyword::Type, Text::Whitespace, Punctuation
# go to kindtest then occurrenceindicator
goto :occurrenceindicator
push :kindtest
end
rule /(#{XPath.kindTestForPi})(\s*)(#{XPath.openParen})/ do
groups Keyword::Type, Text, Punctuation
groups Keyword::Type, Text::Whitespace, Punctuation
# go to kindtestforpi then occurrenceindicator
goto :occurrenceindicator
push :kindtestforpi
end
rule /(item)(\s*)(#{XPath.openParen})(\s*)(\))/ do
goto :occurrenceindicator
groups Keyword::Type, Text, Punctuation, Text, Punctuation
groups Keyword::Type, Text::Whitespace, Punctuation, Text::Whitespace, Punctuation
end
rule /(#{XPath.constructorTypes})(\s*)(#{XPath.openParen})/ do
groups Keyword::Type, Text, Punctuation
groups Keyword::Type, Text::Whitespace, Punctuation
end

# Type commands
rule /(cast|castable)(\s+)(as)/ do
groups Keyword, Text, Keyword
groups Keyword, Text::Whitespace, Keyword
goto :singletype
end
rule /(treat)(\s+)(as)/ do
groups Keyword, Text, Keyword
groups Keyword, Text::Whitespace, Keyword
goto :itemtype
end
rule /(instance)(\s+)(of)/ do
groups Keyword, Text, Keyword
groups Keyword, Text::Whitespace, Keyword
goto :itemtype
end
rule /\b(as)\b/, Keyword
Expand Down Expand Up @@ -240,15 +240,15 @@ def self.constructorTypes
# For pseudo-parameters for the KindTest productions
state :kindtest do
# Whitespace and comments
rule /\s+/m, Text
rule /\s+/m, Text::Whitespace
rule XPath.commentStart, Comment, :comment

# Pseudo-parameters:
rule /[?*]/, Operator
rule /,/, Punctuation
rule /(element|schema-element)(\s*)(#{XPath.openParen})/ do
push :kindtest
groups Keyword::Type, Text, Punctuation
groups Keyword::Type, Text::Whitespace, Punctuation
end
rule XPath.eqName, Name::Tag

Expand All @@ -259,7 +259,7 @@ def self.constructorTypes
# Similar to :kindtest, but recognizes NCNames instead of EQNames
state :kindtestforpi do
# Whitespace and comments
rule /\s+/m, Text
rule /\s+/m, Text::Whitespace
rule XPath.commentStart, Comment, :comment

# Pseudo-parameters
Expand All @@ -272,7 +272,7 @@ def self.constructorTypes

state :occurrenceindicator do
# Whitespace and comments
rule /\s+/m, Text
rule /\s+/m, Text::Whitespace
rule XPath.commentStart, Comment, :comment

# Occurrence indicator
Expand All @@ -289,12 +289,12 @@ def self.constructorTypes

state :varname do
# Whitespace and comments
rule /\s+/m, Text
rule /\s+/m, Text::Whitespace
rule XPath.commentStart, Comment, :comment

# Function call
rule /(#{XPath.eqName})(\s*)(#{XPath.openParen})/ do
groups Name::Variable, Text, Punctuation
groups Name::Variable, Text::Whitespace, Punctuation
pop!
end

Expand All @@ -304,7 +304,7 @@ def self.constructorTypes

state :attrname do
# Whitespace and comments
rule /\s+/m, Text
rule /\s+/m, Text::Whitespace
rule XPath.commentStart, Comment, :comment

# Attribute name
Expand Down
12 changes: 6 additions & 6 deletions lib/rouge/lexers/xquery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def self.keywords
end

rule /(namespace)(\s+)(#{XPath.ncName})/ do
groups Keyword, Text, Name::Namespace
groups Keyword, Text::Whitespace, Name::Namespace
end

rule /\b(#{XQuery.keywords})\b/, Keyword
Expand All @@ -63,20 +63,20 @@ def self.keywords

rule /(\(#)(\s*)(#{XPath.eqName})/ do
push :pragma
groups Comment::Preproc, Text, Name::Tag
groups Comment::Preproc, Text::Whitespace, Name::Tag
end

rule /``\[/, Str, :str_constructor
end

state :annotation do
rule /\s+/m, Text
rule /\s+/m, Text::Whitespace
rule XPath.commentStart, :comment
rule XPath.eqName, Keyword::Declaration, :pop!
end

state :pragma do
rule /\s+/m, Text
rule /\s+/m, Text::Whitespace
rule XPath.commentStart, :comment
rule /#\)/, Comment::Preproc, :pop!
rule /./, Comment::Preproc
Expand All @@ -97,7 +97,7 @@ def self.keywords
end

state :start_tag do
rule /\s+/m, Text
rule /\s+/m, Text::Whitespace
rule /([\w.:-]+\s*=)(")/m do
push :quot_attr
groups Name::Attribute, Str
Expand Down Expand Up @@ -125,7 +125,7 @@ def self.keywords
end

state :tag_content do
rule /\s+/m, Text
rule /\s+/m, Text::Whitespace
mixin :tags

rule /({{|}})/, Text
Expand Down

0 comments on commit 02b524d

Please sign in to comment.