Merge "Parse else ifxxx statement"

This commit is contained in:
Treehugger Robot 2020-11-18 19:09:09 +00:00 committed by Gerrit Code Review
commit 725af86fe7
1 changed files with 14 additions and 1 deletions

View File

@ -212,8 +212,21 @@ func (p *parser) parseDirective() bool {
expression := SimpleMakeString("", pos)
switch d {
case "endif", "endef", "else":
case "endif", "endef":
// Nothing
case "else":
p.ignoreSpaces()
if p.tok != '\n' {
d = p.scanner.TokenText()
p.accept(scanner.Ident)
if d == "ifdef" || d == "ifndef" || d == "ifeq" || d == "ifneq" {
d = "el" + d
p.ignoreSpaces()
expression = p.parseExpression()
} else {
p.errorf("expected ifdef/ifndef/ifeq/ifneq, found %s", d)
}
}
case "define":
expression, endPos = p.parseDefine()
default: