增加 {与"之间无意义空格的过滤

This commit is contained in:
2022-07-04 19:03:15 +08:00
parent 9f78206f80
commit 89f595c48a
2 changed files with 6 additions and 1 deletions

View File

@ -22,6 +22,7 @@ import (
// Date : 18:11 2022/7/4
func parseLexical(jsonData string) ([]lexicalNode, error) {
jsonData = strings.ReplaceAll(strings.ReplaceAll(jsonData, "\n", ""), "\t", "")
// mt.Println(jsonData)
if len(jsonData) < 2 {
return nil, errors.New("input data is not json")
}
@ -32,6 +33,10 @@ func parseLexical(jsonData string) ([]lexicalNode, error) {
preChar := "-1"
if len(lexicalList) > 0 {
preChar = lexicalList[len(lexicalList)-1].Val
if preChar == objectLeftToken && currentChar == " " {
// 无意义的空格
continue
}
}
if inputCharIsToken(currentChar, preChar) {
// 是关键词