Tracing parser (#11)

* Add tracing to the parser.

* Synthesize a --help flag.

* Parsing now occurs in multiple phases.

1. Reset target.
2. Parse command-line into a "trace" (no values are written to target).
3. Apply traced, parsed values to the target fields.

This is another step in facilitating context-sensitive help and
completion.

* Detect duplicate flags.
This commit is contained in:
Alec Thomas
2018-05-22 00:07:43 -04:00
committed by Gerald Kaszuba
parent 3eb5e285ed
commit ab5cf7e6ef
8 changed files with 247 additions and 77 deletions
+4
View File
@@ -40,6 +40,10 @@ func (t Token) String() string {
}
}
func (t Token) IsEOL() bool {
return t.Type == EOLToken
}
func (t Token) IsAny(types ...TokenType) bool {
for _, typ := range types {
if t.Type == typ {