2022-07-04 18:00:22 +08:00
|
|
|
// Package filter ...
|
|
|
|
//
|
|
|
|
// Description : JSON 词法分析
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 2022-07-04 17:52
|
|
|
|
package filter
|
2022-07-04 18:08:10 +08:00
|
|
|
|
2022-07-04 18:19:04 +08:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
// parseLexical 解析词法
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 18:11 2022/7/4
|
|
|
|
func parseLexical(jsonData string) ([]*lexicalNode, error) {
|
|
|
|
if len(jsonData) < 2 {
|
|
|
|
return nil, errors.New("input data is not json")
|
|
|
|
}
|
|
|
|
for _, itemChar := range jsonData {
|
|
|
|
fmt.Println("============ : ", string(itemChar))
|
|
|
|
}
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// inputCharIsToken 输入字符是否为关键字
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 18:15 2022/7/4
|
|
|
|
func inputCharIsToken(inputChar string) bool {
|
|
|
|
tokenCharList := []string{
|
|
|
|
listLeftToken,
|
|
|
|
listRightToken,
|
|
|
|
objectLeftToken,
|
|
|
|
objectRightToken,
|
|
|
|
keyRightToken,
|
|
|
|
kvPairSplitToken,
|
|
|
|
escapeCharacterToken,
|
|
|
|
}
|
|
|
|
for _, itemChar := range tokenCharList {
|
|
|
|
if itemChar == inputChar {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|