diff --git a/spec/doc.tex b/spec/doc.tex index 49a2cf8b7f176bd5740f600f0b0a4fe95697ff64..8c17aa496cf8c0e2d9ef93c0596ffc937a4b1bc4 100644 --- a/spec/doc.tex +++ b/spec/doc.tex @@ -10,9 +10,9 @@ \usepackage{minted} \usemintedstyle{trac} -% TODO: tweak hilighter -\newminted[AletheVerb]{smtlib2.py -x}{} -\newmintinline[inlineAlethe]{smtlib2.py -x}{} +\renewcommand{\MintedPygmentize}{./highlight.py} +\newminted[AletheVerb]{smt-lib}{} +\newmintinline[inlineAlethe]{smt-lib}{} \usepackage{cite} \usepackage{url} diff --git a/spec/smtlib2.py b/spec/highlight.py old mode 100644 new mode 100755 similarity index 79% rename from spec/smtlib2.py rename to spec/highlight.py index 862a2a3c56f3aa03743241edae4f50bd76e195da..ed78bb3afa9ccb847cdc879f605bcd5b45cba67c --- a/spec/smtlib2.py +++ b/spec/highlight.py @@ -1,19 +1,33 @@ +#! /usr/bin/env python # -*- coding: utf-8 -*- +# This is a thin wraper arround pygmentize that adds support for SMT-LIB/Alethe. +# More precicely: it parses the command line arguments and uses a custom +# SMT-LIB lexer if the user selects smt-lib as the language. +# This wrapper was made necessary by version 2.7 of minted: it started to +# quote command line arguments hended to pygmentize and thereby made the old +# tick to use "smtlib2.py -x" as the language unworkable. + import re +import argparse +import sys -from pygments.lexer import Lexer, RegexLexer, bygroups, do_insertions, \ - default, include +import pygments.cmdline as _cmdline +from pygments.lexer import RegexLexer from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ - Number, Punctuation, Generic -from pygments import unistring as uni - -__all__ = ['Smt2Lexer'] + Number, Punctuation +def main(args): + parser = argparse.ArgumentParser() + parser.add_argument('-l', dest='lexer', type=str) + opts, rest = parser.parse_known_args(args[1:]) + if opts.lexer == 'smt-lib': + args = [__file__, '-l', __file__ + ':SMTLibLexer', '-x', *rest] + _cmdline.main(args) line_re = re.compile('.*?\n') -class CustomLexer(RegexLexer): +class SMTLibLexer(RegexLexer): """ A SMT-Lib 2 parser """ @@ -117,3 +131,6 @@ class CustomLexer(RegexLexer): (r'[^()]+', Comment), ], } + +if __name__ == '__main__': + main(sys.argv) \ No newline at end of file