From f08f75266e7ed1b8c5cabed0ee30b7fac9269624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Mon, 4 Jul 2022 18:19:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E6=98=AF=E5=90=A6=E4=B8=BA=E5=85=B3=E9=94=AE=E8=AF=8D?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lexical.go | 43 +++++++++++++++++++++++++++++++++++++++++++ lexical_test.go | 16 ++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 lexical_test.go diff --git a/lexical.go b/lexical.go index 57ef9b2..81790dc 100644 --- a/lexical.go +++ b/lexical.go @@ -7,3 +7,46 @@ // Date : 2022-07-04 17:52 package filter +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 +} diff --git a/lexical_test.go b/lexical_test.go new file mode 100644 index 0000000..87e9e57 --- /dev/null +++ b/lexical_test.go @@ -0,0 +1,16 @@ +// Package filter ... +// +// Description : filter ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 2022-07-04 18:13 +package filter + +import ( + "testing" +) + +func Test_parseLexical(t *testing.T) { + parseLexical("{iiiiiiiii}") +}