diff options
author | Logan Chien <loganchien@google.com> | 2018-06-25 11:52:48 +0800 |
---|---|---|
committer | Logan Chien <loganchien@google.com> | 2018-06-26 12:20:08 +0800 |
commit | 3deba3df45410b68bb9e855be558d1053c3cdfc2 (patch) | |
tree | b3a295c4b4aaa56ca3d51aa9dfa8dfb6a3e28dcf | |
parent | 3b3bd2aac06df69c50ac3653a0cf2822d806cbfd (diff) | |
download | android_build_blueprint-3deba3df45410b68bb9e855be558d1053c3cdfc2.tar.gz android_build_blueprint-3deba3df45410b68bb9e855be558d1053c3cdfc2.tar.bz2 android_build_blueprint-3deba3df45410b68bb9e855be558d1053c3cdfc2.zip |
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
-rw-r--r-- | parser/parser.go | 6 | ||||
-rw-r--r-- | parser/printer_test.go | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/parser/parser.go b/parser/parser.go index e832e1a..cb86246 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -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 diff --git a/parser/printer_test.go b/parser/printer_test.go index 7289441..6f76b26 100644 --- a/parser/printer_test.go +++ b/parser/printer_test.go @@ -33,7 +33,7 @@ foo {} }, { input: ` -foo{name= "abc",num= 4,} +foo(name= "abc",num= 4,) `, output: ` foo { |