Created
April 12, 2010 07:03
-
-
Save malthe/363342 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RapidSMSLexer(RegexLexer): | |
""" | |
Lexer for RapidSMS text messages. | |
""" | |
name = 'RapidSMS' | |
aliases = ['sms'] | |
filenames = [] | |
mimetypes = ['application/x-rapidsms'] | |
flags = re.MULTILINE | re.IGNORECASE | |
tokens = { | |
'root': [ | |
(r'^>>>\s*', Generic.Prompt), | |
(r'^<<<\s*', Generic.Prompt), | |
(r'\+\w+\s*', Name.Label), | |
include('basic'), | |
(r'.', Text), | |
], | |
'basic': [ | |
(r'".*?"', String.Double), | |
(r"'.*?'", String.Single), | |
(r'`.*?`', String.Backtick), | |
(r'-?\d+', Number), | |
(r',', Punctuation), | |
(r'=', Operator), | |
(r'/\S+', Name), | |
(r':\w+', Name.Label), | |
(r'\w:\w+', Text), | |
(r'([<>|])(\s*)(\w+)', bygroups(Punctuation, Text, Name)), | |
], | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment