Emit errors on mixed property syntax

This commit refines `compat` condition in `parseProperty()` so that a
module definition would either use the new syntax or the old syntax,
but not something in the between, such as

    cc_library {
        name: "bad_example",
        srcs= ["bad.c"],
    }

Test: lunch aosp_arm64-userdebug; make  # runs unit test
Change-Id: If2d3e5d55edccc28d314d99b83b0f54e5c53ac35
This commit is contained in:
Logan Chien 2018-06-25 11:52:48 +08:00
parent 3b3bd2aac0
commit 3deba3df45
2 changed files with 5 additions and 3 deletions

View file

@ -302,8 +302,10 @@ func (p *parser) parseProperty(isModule, compat bool) (property *Property) {
pos := p.scanner.Position
if isModule {
if compat && p.tok == ':' {
p.accept(':')
if compat {
if !p.accept(':') {
return
}
} else {
if !p.accept('=') {
return

View file

@ -33,7 +33,7 @@ foo {}
},
{
input: `
foo{name= "abc",num= 4,}
foo(name= "abc",num= 4,)
`,
output: `
foo {