浏览代码

Allow variables whose names start with commands

Now 'h' will no longer match the start of 'hello' and cause a parse
error.
Ryan C. Thompson 6 年之前
父节点
当前提交
f6f9d8f992
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      roll.py

+ 3 - 3
roll.py

@@ -167,9 +167,9 @@ def DeleteCommand(): return (
         Whitespace,
         UnevaluatedVariable,
 )
-def HelpCommand(): return Combine(['help', 'h', '?'])
-def QuitCommand(): return Combine(['quit', 'exit', 'q'])
-def ListVarsCommand(): return Combine(['variables', 'vars', 'v'])
+def HelpCommand(): return Combine(['help', 'h', '?'], Not(Identifier))
+def QuitCommand(): return Combine(['quit', 'exit', 'q'], Not(Identifier))
+def ListVarsCommand(): return Combine(['variables', 'vars', 'v'], Not(Identifier))
 def Command(): return [ ListVarsCommand, DeleteCommand, HelpCommand, QuitCommand, ]
 
 def InputParser(): return Optional([Command, VarAssignment, Expression, Whitespace])