Bladeren bron

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 jaren geleden
bovenliggende
commit
f6f9d8f992
1 gewijzigde bestanden met toevoegingen van 3 en 3 verwijderingen
  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])