codekingpro/portable-devtools
114k
1"""2 pygments.lexers.pddl3 ~~~~~~~~~~~~~~~~~~~~4 5 Lexer for the Planning Domain Definition Language.6 7 :copyright: Copyright 2006-present by the Pygments team, see AUTHORS.8 :license: BSD, see LICENSE for details.9"""10 11 12from pygments.lexer import RegexLexer, words, include13from pygments.token import Punctuation, Keyword, Whitespace, Name, Comment, \14 Operator, Number15 16 17__all__ = ['PddlLexer']18 19 20class PddlLexer(RegexLexer):21 """22 A PDDL lexer.23 24 It should support up to PDDL 3.1.25 """26 27 name = 'PDDL'28 aliases = ['pddl']29 filenames = ['*.pddl']30 # there doesn't really seem to be a PDDL homepage.31 url = 'https://en.wikipedia.org/wiki/Planning_Domain_Definition_Language'32 version_added = '2.19'33 34 tokens = {35 'root': [36 (r'\s+', Whitespace),37 (r';.*$', Comment.Singleline),38 include('keywords'),39 include('builtins'),40 (r'[()]', Punctuation),41 (r'[=/*+><-]', Operator),42 (r'[a-zA-Z][a-zA-Z0-9_-]*', Name),43 (r'\?[a-zA-Z][a-zA-Z0-9_-]*', Name.Variable),44 (r'[0-9]+\.[0-9]+', Number.Float),45 (r'[0-9]+', Number.Integer),46 ],47 'keywords': [48 (words((49 ':requirements', ':types', ':constants',50 ':predicates', ':functions', ':action', ':agent',51 ':parameters', ':precondition', ':effect',52 ':durative-action', ':duration', ':condition',53 ':derived', ':domain', ':objects', ':init',54 ':goal', ':metric', ':length', ':serial', ':parallel',55 # the following are requirements56 ':strips', ':typing', ':negative-preconditions',57 ':disjunctive-preconditions', ':equality',58 ':existential-preconditions', ':universal-preconditions',59 ':conditional-effects', ':fluents', ':numeric-fluents',60 ':object-fluents', ':adl', ':durative-actions',61 ':continuous-effects', ':derived-predicates',62 ':time-intial-literals', ':preferences',63 ':constraints', ':action-costs', ':multi-agent',64 ':unfactored-privacy', ':factored-privacy',65 ':non-deterministic'66 ), suffix=r'\b'), Keyword)67 ],68 'builtins': [69 (words((70 'define', 'domain', 'object', 'either', 'and',71 'forall', 'preference', 'imply', 'or', 'exists',72 'not', 'when', 'assign', 'scale-up', 'scale-down',73 'increase', 'decrease', 'at', 'over', 'start',74 'end', 'all', 'problem', 'always', 'sometime',75 'within', 'at-most-once', 'sometime-after',76 'sometime-before', 'always-within', 'hold-during',77 'hold-after', 'minimize', 'maximize',78 'total-time', 'is-violated'), suffix=r'\b'),79 Name.Builtin)80 ]81 }82 83 