diff options
| author | mryouse | 2022-07-15 00:22:49 +0000 |
|---|---|---|
| committer | mryouse | 2022-07-15 00:22:49 +0000 |
| commit | 0fd87cd92a3777f8823c466a71c341f9ae0292e3 (patch) | |
| tree | 6056aee9a8d5691781704ccf6dc3c441e2534a5a | |
| parent | e7d48002ed31bca4c91e28037c29aefd7b88a951 (diff) | |
add support for single quote
| -rw-r--r-- | neb/__init__.py | 2 | ||||
| -rw-r--r-- | neb/parser.py | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/neb/__init__.py b/neb/__init__.py index e93f0dd..a50652d 100644 --- a/neb/__init__.py +++ b/neb/__init__.py @@ -15,6 +15,8 @@ def evaluate(expr, env, ns=None): if isinstance(expr, Literal) or isinstance(expr, Callable) or isinstance(expr, TypeWrap) or isinstance(expr, List) or isinstance(expr, Handle): return expr elif isinstance(expr, Symbol) or isinstance(expr, Type): + if isinstance(expr, Symbol) and expr.quoted: + return Symbol(expr.name, expr.line) if env.contains(expr.name): if isinstance(expr, Type) and expr.inner is not None: typecopy = deepcopy(env.get(expr.name)) diff --git a/neb/parser.py b/neb/parser.py index d5712d2..22c51e4 100644 --- a/neb/parser.py +++ b/neb/parser.py @@ -29,7 +29,10 @@ def parseExpression(token, prev, tokens): return Expr(args), idx + 2 # parens def parseSymbol(token, prev, tokens): - return Symbol(token.text, token.line), 1 + if token.text.startswith("'"): + return Symbol(token.text[1:], token.line, True), 1 + else: + return Symbol(token.text, token.line), 1 def parseLiteral(token, prev, tokens): if token.type_ == TokenType.STRING: |
