parent
195bfd98c7
commit
8ab8c86bf4
28
mode/go.py
28
mode/go.py
|
@ -16,21 +16,23 @@ chr1 = '[a-zA-Z_]'
|
||||||
chr2 = '[a-zA-Z0-9_]'
|
chr2 = '[a-zA-Z0-9_]'
|
||||||
word = chr1 + chr2 + '*'
|
word = chr1 + chr2 + '*'
|
||||||
|
|
||||||
|
escaped = [
|
||||||
|
PatternRule('escaped', r'\\[abfnrtv\\\'"]'),
|
||||||
|
PatternRule('octal', r'\\[0-7]{3}'),
|
||||||
|
PatternRule('hex', r'\\x[a-fA-F0-9]{2}'),
|
||||||
|
PatternRule('unicode', r'\\u[a-fA-F0-9]{4}'),
|
||||||
|
PatternRule('unicode', r'\\U[a-fA-F0-9]{8}'),
|
||||||
|
PatternRule('illegal', r'\\.*'),
|
||||||
|
]
|
||||||
|
|
||||||
class StringGrammar(Grammar):
|
class StringGrammar(Grammar):
|
||||||
rules = [
|
rules = escaped + [PatternRule('data', r'[^\\"]+')]
|
||||||
PatternRule('escaped', r'\\[abfnrtv\\\'"]'),
|
|
||||||
PatternRule('octal', r'\\[0-7]{3}'),
|
class CharGrammar(Grammar):
|
||||||
PatternRule('hex', r'\\x[a-fA-F0-9]{2}'),
|
rules = escaped + [PatternRule('data', r"[^\\']+")]
|
||||||
PatternRule('unicode', r'\\u[a-fA-F0-9]{4}'),
|
|
||||||
PatternRule('unicode', r'\\U[a-fA-F0-9]{8}'),
|
|
||||||
PatternRule('illegal', r'\\.*'),
|
|
||||||
PatternRule('data', r'[^\\"]+'),
|
|
||||||
]
|
|
||||||
|
|
||||||
class RawStringGrammar(Grammar):
|
class RawStringGrammar(Grammar):
|
||||||
rules = [
|
rules = [PatternRule('data', '[^`]+')]
|
||||||
PatternRule('data', '[^`]+'),
|
|
||||||
]
|
|
||||||
|
|
||||||
class GoGrammar(Grammar):
|
class GoGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
|
@ -51,7 +53,7 @@ class GoGrammar(Grammar):
|
||||||
|
|
||||||
PatternRule('go.integer', r'(?:[1-9][0-9]*|0[0-9]*|0[xX][a-fA-F0-9]+)'),
|
PatternRule('go.integer', r'(?:[1-9][0-9]*|0[0-9]*|0[xX][a-fA-F0-9]+)'),
|
||||||
|
|
||||||
RegionRule('go.char', "'", StringGrammar, "'"),
|
RegionRule('go.char', "'", CharGrammar, "'"),
|
||||||
RegionRule('go.string', '"', StringGrammar, '"'),
|
RegionRule('go.string', '"', StringGrammar, '"'),
|
||||||
RegionRule('go.string', '`', RawStringGrammar, '`'),
|
RegionRule('go.string', '`', RawStringGrammar, '`'),
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue