summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Inozemtsev <ivan.inozemtsev@xored.com>2012-02-05 16:44:04 +0700
committerIvan Inozemtsev <ivan.inozemtsev@xored.com>2012-02-05 16:44:04 +0700
commit5bec10613bea7da737b1549f08a1b943ab8d484f (patch)
tree6e0e8176389aa7855b67e1611cf85ccd88b51ebc
parentcbc95806217ac10426af8a50d3379ecea6acc133 (diff)
downloadpygments-5bec10613bea7da737b1549f08a1b943ab8d484f.tar.gz
Fixed few bugs in fantom lexer
-rw-r--r--pygments/lexers/_mapping.py1
-rw-r--r--pygments/lexers/compiled.py57
2 files changed, 37 insertions, 21 deletions
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py
index 4772a9a0..5525e1a8 100644
--- a/pygments/lexers/_mapping.py
+++ b/pygments/lexers/_mapping.py
@@ -85,6 +85,7 @@ LEXERS = {
'FSharpLexer': ('pygments.lexers.dotnet', 'FSharp', ('fsharp',), ('*.fs', '*.fsi'), ('text/x-fsharp',)),
'FactorLexer': ('pygments.lexers.agile', 'Factor', ('factor',), ('*.factor',), ('text/x-factor',)),
'FancyLexer': ('pygments.lexers.agile', 'Fancy', ('fancy', 'fy'), ('*.fy', '*.fancypack'), ('text/x-fancysrc',)),
+ 'FantomLexer': ('pygments.lexers.compiled', 'Fantom', ('fan',), ('*.fan',), ()),
'FelixLexer': ('pygments.lexers.compiled', 'Felix', ('felix', 'flx'), ('*.flx', '*.flxh'), ('text/x-felix',)),
'FortranLexer': ('pygments.lexers.compiled', 'Fortran', ('fortran',), ('*.f', '*.f90', '*.F', '*.F90'), ('text/x-fortran',)),
'GLShaderLexer': ('pygments.lexers.compiled', 'GLSL', ('glsl',), ('*.vert', '*.frag', '*.geo'), ('text/x-glslsrc',)),
diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py
index 7a269e49..2bc13c1b 100644
--- a/pygments/lexers/compiled.py
+++ b/pygments/lexers/compiled.py
@@ -2895,7 +2895,7 @@ class FantomLexer(RegexLexer):
def s(str):
return Template(str).substitute(
dict (
- pod = r'[\"\"\w\.]+',
+ pod = r'[\"\w\.]+',
eos = r'\n|;',
id = r'[a-zA-Z_][a-zA-Z0-9_]*',
type = r'(?:\[|[a-zA-Z_]|\|)[:\w_\[\]\|\->\?]*?' # all chars which can be part of type definition. Starts with either letter, or [ (maps), or | (funcs)
@@ -2906,31 +2906,32 @@ class FantomLexer(RegexLexer):
tokens = {
'comments' : [
(r'(?s)/\*.*?\*/', Comment.Multiline), #Multiline
- (r'//.*?\n', Comment), #Single line
+ (r'//.*?\n', Comment.Single), #Single line
#todo: highlight references in fandocs
- (r'\*\*.*?\n', Comment.Special) #Fandoc
+ (r'\*\*.*?\n', Comment.Special), #Fandoc
+ (r'#.*\n', Comment.Single) #Shell-style comment
],
'literals' : [
- (r'-?[\d_]+(ns|ms|sec|min|hr|day)', Number), #Duration
- (r'-?[\d_]*\.[\d_]+(ns|ms|sec|min|hr|day)', Number), #Duration with dot
- (r'-?(\d+)?\.\d+(f|F|d|D)?', Number.Float), #Float/Decimal
- (r'-?0x[0-9a-fA-F_]+', Number.Hex), #Hex
- (r'-?[\d_]+', Number.Integer), #Int
+ (r'\b-?[\d_]+(ns|ms|sec|min|hr|day)', Number), #Duration
+ (r'\b-?[\d_]*\.[\d_]+(ns|ms|sec|min|hr|day)', Number), #Duration with dot
+ (r'\b-?(\d+)?\.\d+(f|F|d|D)?', Number.Float), #Float/Decimal
+ (r'\b-?0x[0-9a-fA-F_]+', Number.Hex), #Hex
+ (r'\b-?[\d_]+', Number.Integer), #Int
(r"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char), #Char
(r'"', Punctuation, 'insideStr'), #Opening quote
(r'`', Punctuation, 'insideUri'), #Opening accent
- (r'\b(true|false|null)\b', Keyword.Constant), #Bool & null
+ (r'\b(true|false|null)\b', Keyword.Constant), #Bool & null
(r'(?:(\w+)(::))?(\w+)(<\|)(.*?)(\|>)', #DSL
bygroups(Name.Namespace, Punctuation, Name.Class,
Punctuation, String, Punctuation)),
- (r'(\w+)?(::)?(\w+)?(#)(\w+)?', #Type/slot literal
+ (r'(?:(\w+)(::))?(\w+)?(#)(\w+)?', #Type/slot literal
bygroups(Name.Namespace, Punctuation, Name.Class,
Punctuation, Name.Function)),
(r'\[,\]', Literal), # Empty list
(s(r'($type)(\[,\])'), # Typed empty list
bygroups(using(this, state = 'inType'), Literal)),
(r'\[:\]', Literal), # Empty Map
- (r'($type)(\[:\])',
+ (s(r'($type)(\[:\])'),
bygroups(using(this, state = 'inType'), Literal)),
],
'insideStr' : [
@@ -2971,10 +2972,9 @@ class FantomLexer(RegexLexer):
],
'operators' : [
- (r'\+\+|--|\+|-|\*|/|\|\||&&|<=>|<=|<|>=|>|=|!', Operator)
+ (r'\+\+|\-\-|\+|\-|\*|/|\|\||&&|<=>|<=|<|>=|>|=|!|\[|\]', Operator)
],
'inType' : [
-# include('types'),
(r'[\[\]\|\->:\?]', Punctuation),
(s(r'$id'), Name.Class),
(r'', Text, '#pop'),
@@ -2989,14 +2989,13 @@ class FantomLexer(RegexLexer):
include('literals'),
include('otherKeywords'),
include('operators'),
-# include('types'),
(r'using\b', Keyword.Namespace, 'using'), #Using stmt
(r'@\w+', Name.Decorator, 'facet'), #Symbol
(r'(class|mixin)(\s+)(\w+)',
bygroups(Keyword, Text, Name.Class), 'inheritance'),#Inheritance list
- #Type var := val
+ ### Type var := val
(s(r'($type)([ \t]+)($id)(\s*)(:=)'),
bygroups(using(this, state = 'inType'), Text,
Name.Variable, Text, Operator)),
@@ -3006,12 +3005,12 @@ class FantomLexer(RegexLexer):
bygroups(Name.Variable, Text, Operator)),
### .someId( or ->someId( ###
- (s(r'(\.|(?:->))($id)(\s*)(\()'),
+ (s(r'(\.|(?:\->))($id)(\s*)(\()'),
bygroups(Operator, Name.Function, Text, Punctuation),
'insideParen'),
### .someId or ->someId
- (s(r'(\.|(?:->))($id)'),
+ (s(r'(\.|(?:\->))($id)'),
bygroups(Operator, Name.Function)),
### new makeXXX ( ####
@@ -3025,7 +3024,7 @@ class FantomLexer(RegexLexer):
bygroups(using(this, state = 'inType'), Text,
Name.Function, Text, Punctuation), 'insideMethodDeclArgs'),
- #### ArgType argName, #####
+ ### ArgType argName, #####
(s(r'($type)(\s+)($id)(\s*)(,)'),
bygroups(using(this, state= 'inType'), Text, Name.Variable,
Text, Punctuation)),
@@ -3033,6 +3032,22 @@ class FantomLexer(RegexLexer):
#### ArgType argName) ####
## Covered in 'insideParen' state
+ ### ArgType argName -> ArgType| ###
+ (s(r'($type)(\s+)($id)(\s*)(\->)(\s*)($type)(\|)'),
+ bygroups(using(this, state= 'inType'), Text, Name.Variable,
+ Text, Punctuation, Text, using(this, state = 'inType'),
+ Punctuation)),
+
+ ### ArgType argName| ###
+ (s(r'($type)(\s+)($id)(\s*)(\|)'),
+ bygroups(using(this, state= 'inType'), Text, Name.Variable,
+ Text, Punctuation)),
+
+ ### Type var
+ (s(r'($type)([ \t]+)($id)'),
+ bygroups(using(this, state='inType'), Text,
+ Name.Variable)),
+
(r'\(', Punctuation, 'insideParen'),
(r'\{', Punctuation, 'insideBrace'),
(r'.', Text)
@@ -3083,10 +3098,10 @@ class FantomLexer(RegexLexer):
'facetFields': [
include('comments'),
include('literals'),
+ include('operators'),
(r'\s+', Text),
(r'(\s*)(\w+)(\s*)(=)', bygroups(Text, Name, Text, Operator)),
- (r'}', Punctuation, '#pop')
+ (r'}', Punctuation, '#pop'),
+ (r'.', Text)
],
-
-
}