parsePhraseCommand also generates a phrase kind value
This commit is contained in:
parent
977ecba78c
commit
48f72e614b
@ -311,24 +311,40 @@ func (parser *ParsingOperation) parsePhraseCommand () (
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = parser.nextToken()
|
err = parser.nextToken()
|
||||||
if err != nil { return }
|
return
|
||||||
} else {
|
}
|
||||||
command, err = parser.parseArgument()
|
|
||||||
if err != nil { return }
|
|
||||||
|
|
||||||
if command.kind == ArgumentKindString {
|
// phrase command is not an operator, it is just a normal argument
|
||||||
kind = PhraseKindCallExternal
|
command, err = parser.parseArgument()
|
||||||
|
if err != nil { return }
|
||||||
|
|
||||||
|
// determine semantic role of phrase
|
||||||
|
if command.kind == ArgumentKindString {
|
||||||
|
kind = PhraseKindCallExternal
|
||||||
|
|
||||||
|
} else if command.kind == ArgumentKindIdentifier {
|
||||||
|
identifier := command.value.(Identifier)
|
||||||
|
if len(identifier.trail) == 1 {
|
||||||
|
switch identifier.trail[0] {
|
||||||
|
case "set":
|
||||||
|
kind = PhraseKindSet
|
||||||
|
case "defer":
|
||||||
|
kind = PhraseKindDefer
|
||||||
|
case "if":
|
||||||
|
kind = PhraseKindIf
|
||||||
|
case "elseif":
|
||||||
|
kind = PhraseKindElseIf
|
||||||
|
case "else":
|
||||||
|
kind = PhraseKindElse
|
||||||
|
case "switch":
|
||||||
|
kind = PhraseKindSwitch
|
||||||
|
case "while":
|
||||||
|
kind = PhraseKindWhile
|
||||||
|
case "for":
|
||||||
|
kind = PhraseKindFor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// PhraseKindSet
|
|
||||||
// PhraseKindDefer
|
|
||||||
// PhraseKindIf
|
|
||||||
// PhraseKindElseIf
|
|
||||||
// PhraseKindElse
|
|
||||||
// PhraseKindSwitch
|
|
||||||
// PhraseKindWhile
|
|
||||||
// PhraseKindFor
|
|
||||||
|
Reference in New Issue
Block a user