lib/rouge/lexers/igorpro.rb in rouge-2.1.1 vs lib/rouge/lexers/igorpro.rb in rouge-2.2.0
- old
+ new
@@ -17,10 +17,11 @@
macro proc window menu function end
if else elseif endif switch strswitch endswitch
break return continue
for endfor do while
case default
+ try catch endtry
abortonrte
)
end
def self.preprocessor
@@ -245,26 +246,25 @@
hdf5dumpstate hdf5dump hdf5dumperrors
)
end
def self.object_name
- /[a-z][a-z0-9_]*\b/i
+ /\b[a-z][a-z0-9_\.]*?\b/i
end
object = self.object_name
- whitespace = /[\s\r]+/
- noLineBreak = /[ \t]+/
+ noLineBreak = /(?:[ \t]|(?:\\\s*[\r\n]))+/
operator = %r([\#$~!%^&*+=\|?:<>/-])
punctuation = /[{}()\[\],.;]/
number_float= /0x[a-f0-9]+/i
number_hex = /\d+\.\d+(e[\+\-]?\d+)?/
number_int = /[\d]+(?:_\d+)*/
state :root do
rule %r(//), Comment, :comments
- rule /\b#{object}/ do |m|
+ rule /#{object}/ do |m|
if m[0].downcase =~ /function/
token Keyword::Declaration
push :parse_function
elsif self.class.igorDeclarations.include? m[0].downcase
token Keyword::Declaration
@@ -279,22 +279,23 @@
token Keyword::Reserved
push :operationFlags
elsif self.class.hdf5Operation.include? m[0].downcase
token Keyword::Reserved
push :operationFlags
- elsif m[0].downcase =~ /(v|s|w)_[a-z]+[a-z0-9]*/
- token Name::Builtin
+ elsif m[0].downcase =~ /\b(v|s|w)_[a-z]+[a-z0-9]*/
+ token Name::Constant
else
token Name
end
end
mixin :preprocessor
mixin :waveFlag
mixin :characters
mixin :numbers
+ mixin :whitespace
end
state :preprocessor do
rule %r((\#)(#{object})) do |m|
if self.class.preprocessor.include? m[2].downcase
@@ -308,11 +309,11 @@
end
end
state :assignment do
mixin :whitespace
- rule /\"/, Punctuation, :string1
+ rule /\"/, Literal::String::Double, :string1 #punctuation for string
mixin :string2
rule /#{number_float}/, Literal::Number::Float, :pop!
rule /#{number_int}/, Literal::Number::Integer, :pop!
rule /[\(\[\{][^\)\]\}]+[\)\]\}]/, Generic, :pop!
rule /[^\s\/\(]+/, Generic, :pop!
@@ -320,15 +321,15 @@
end
state :parse_variables do
mixin :whitespace
rule /[=]/, Punctuation, :assignment
- rule %r([/][a-z]+)i, Keyword::Pseudo, :parse_variables
rule object, Name::Variable
rule /[\[\]]/, Punctuation # optional variables in functions
rule /[,]/, Punctuation, :parse_variables
rule /\)/, Punctuation, :pop! # end of function
+ rule %r([/][a-z]+)i, Keyword::Pseudo, :parse_variables
rule(//) { pop! }
end
state :parse_function do
rule %r([/][a-z]+)i, Keyword::Pseudo # only one flag
@@ -365,11 +366,11 @@
state :characters do
rule /\s/, Text
rule /#{operator}/, Operator
rule /#{punctuation}/, Punctuation
- rule /\"/, Punctuation, :string1
+ rule /\"/, Literal::String::Double, :string1 #punctuation for string
mixin :string2
end
state :numbers do
rule /#{number_float}/, Literal::Number::Float
@@ -385,10 +386,10 @@
rule /%\w\b/, Literal::String::Other
rule /\\\\/, Literal::String::Escape
rule /\\\"/, Literal::String::Escape
rule /\\/, Literal::String::Escape
rule /[^"]/, Literal::String
- rule /\"/, Punctuation, :pop!
+ rule /\"/, Literal::String::Double, :pop! #punctuation for string
end
state :string2 do
rule /\'[^']*\'/, Literal::String::Single
end