mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.cc] cmd/asm: fix the expression parser and add tests
Rewrite the grammar to have one more production so it parses ~0*0 correctly and write tests to prove it. Change-Id: I0dd652baf65b48a3f26c9287c420702db4eaec59 Reviewed-on: https://go-review.googlesource.com/3443 Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
ad82238653
commit
0012b83507
4 changed files with 132 additions and 46 deletions
|
|
@ -46,7 +46,7 @@ func predefine(defines flags.MultiFlag) map[string]*Macro {
|
|||
if i > 0 {
|
||||
name, value = name[:i], name[i+1:]
|
||||
}
|
||||
tokens := tokenize(name)
|
||||
tokens := Tokenize(name)
|
||||
if len(tokens) != 1 || tokens[0].ScanToken != scanner.Ident {
|
||||
fmt.Fprintf(os.Stderr, "asm: parsing -D: %q is not a valid identifier name\n", tokens[0])
|
||||
flags.Usage()
|
||||
|
|
@ -54,7 +54,7 @@ func predefine(defines flags.MultiFlag) map[string]*Macro {
|
|||
macros[name] = &Macro{
|
||||
name: name,
|
||||
args: nil,
|
||||
tokens: tokenize(value),
|
||||
tokens: Tokenize(value),
|
||||
}
|
||||
}
|
||||
return macros
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue