codekingpro/portable-devtools
114k
1"""2 pygments.lexers.pointless3 ~~~~~~~~~~~~~~~~~~~~~~~~~4 5 Lexers for Pointless.6 7 :copyright: Copyright 2006-present by the Pygments team, see AUTHORS.8 :license: BSD, see LICENSE for details.9"""10 11from pygments.lexer import RegexLexer, words12from pygments.token import Comment, Error, Keyword, Name, Number, Operator, \13 Punctuation, String, Text14 15__all__ = ['PointlessLexer']16 17 18class PointlessLexer(RegexLexer):19 """20 For Pointless source code.21 """22 23 name = 'Pointless'24 url = 'https://ptls.dev'25 aliases = ['pointless']26 filenames = ['*.ptls']27 version_added = '2.7'28 29 ops = words([30 "+", "-", "*", "/", "**", "%", "+=", "-=", "*=",31 "/=", "**=", "%=", "|>", "=", "==", "!=", "<", ">",32 "<=", ">=", "=>", "$", "++",33 ])34 35 keywords = words([36 "if", "then", "else", "where", "with", "cond",37 "case", "and", "or", "not", "in", "as", "for",38 "requires", "throw", "try", "catch", "when",39 "yield", "upval",40 ], suffix=r'\b')41 42 tokens = {43 'root': [44 (r'[ \n\r]+', Text),45 (r'--.*$', Comment.Single),46 (r'"""', String, 'multiString'),47 (r'"', String, 'string'),48 (r'[\[\](){}:;,.]', Punctuation),49 (ops, Operator),50 (keywords, Keyword),51 (r'\d+|\d*\.\d+', Number),52 (r'(true|false)\b', Name.Builtin),53 (r'[A-Z][a-zA-Z0-9]*\b', String.Symbol),54 (r'output\b', Name.Variable.Magic),55 (r'(export|import)\b', Keyword.Namespace),56 (r'[a-z][a-zA-Z0-9]*\b', Name.Variable)57 ],58 'multiString': [59 (r'\\.', String.Escape),60 (r'"""', String, '#pop'),61 (r'"', String),62 (r'[^\\"]+', String),63 ],64 'string': [65 (r'\\.', String.Escape),66 (r'"', String, '#pop'),67 (r'\n', Error),68 (r'[^\\"]+', String),69 ],70 }71 