Explain the states in the argument parser

This commit is contained in:
Sei Lisa 2019-01-05 00:45:25 +01:00
parent 40cd88e9f7
commit 1a83213a40

View file

@ -71,13 +71,20 @@ def parseArgs(s):
args = [] args = []
# States # States
Space = 0 Space = 0 # Space between args.
SBackslash = 1 SBackslash = 1 # Backslash after space. Returns to Space if followed
Normal = 2 # by LF, otherwise inserts the character verbatim and
NBackslash = 3 # goes to Normal.
DQuote = 4 Normal = 2 # Normal argument.
DQBackslash = 5 NBackslash = 3 # Backslash in Normal mode. Returns to Normal if
SQuote = 6 # followed by LF, otherwise inserts the character
# verbatim.
DQuote = 4 # Double quote mode.
DQBackslash = 5 # Backslash in double quote mode. Returns to DQuote if
# followed by LF; inserts the character verbatim if
# followed by '"', '`', '$' or '\' and inserts a '\'
# plus the character verbatim in any other case.
SQuote = 6 # Single quote mode.
State = Space State = Space
p = 0 p = 0