diff --git a/lamb/__main__.py b/lamb/__main__.py index c3cc3da..7f615624 100755 --- a/lamb/__main__.py +++ b/lamb/__main__.py @@ -4,6 +4,7 @@ from prompt_toolkit import print_formatted_text as printf from prompt_toolkit.formatted_text import FormattedText from prompt_toolkit.formatted_text import to_plain_text from prompt_toolkit.key_binding import KeyBindings +from prompt_toolkit.lexers import Lexer from pyparsing import exceptions as ppx @@ -14,6 +15,14 @@ import lamb.tokens as tokens import lamb.utils as utils +# Simple lexer for highlighting. +# Improve this later. +class LambdaLexer(Lexer): + def lex_document(self, document): + def inner(line_no): + return [("class:text", str(document.lines[line_no]))] + return inner + # Replace "\" with a pretty "λ" in the prompt bindings = KeyBindings() @bindings.add("\\") @@ -25,6 +34,7 @@ session = PromptSession( ("class:prompt", "~~> ") ]), style = utils.style, + lexer = LambdaLexer(), key_bindings = bindings )