Skip to content

Commit

Permalink
chore: disable structtag check to improve readability of parser
Browse files Browse the repository at this point in the history
  • Loading branch information
mathnogueira committed May 3, 2022
1 parent a8b766a commit 423f5a0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ server-test:
cd server; go test ./...

server-vet:
cd server; go vet ./...
cd server; go vet -structtag=false ./...

server-run:
cd server; go run main.go
Expand Down
29 changes: 14 additions & 15 deletions server/engine/selectors/parser.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//nolint directives: structtag
package selectors

import (
Expand All @@ -8,32 +7,32 @@ import (
)

type Selector struct {
SpanSelector []SpanSelector `parser:"( @@* ( \",\" @@ )*)"`
SpanSelector []SpanSelector `( @@* ( "," @@ )*)` //nolint
}

type SpanSelector struct {
Filters []Filter `parser:"\"span\"\"[\"( @@* ( \",\" @@)*)\"]\""`
PseudoClass PseudoClass `parser:"@@*"`
ChildSelector *SpanSelector `parser:" @@*"`
Filters []Filter `"span""["( @@* ( "," @@)*)"]"`
PseudoClass PseudoClass `@@*`
ChildSelector *SpanSelector ` @@*`
}

type Filter struct {
Property string `parser:"( @Ident ( @\".\" @Ident )*)"`
Operator string `parser:"@(\"=\" | \"contains\" )"`
Value *Value `parser:"@@*"`
Property string `( @Ident ( @"." @Ident )*)`
Operator string `@("=" | "contains" )`
Value *Value `@@*`
}

type Value struct {
String *string `parser:" @String"`
Int *int64 `parser:" | @Int"`
Float *float64 `parser:" | @Float"`
Boolean *bool `parser:" | @(\"true\" | \"false\")"`
Null bool `parser:" | @\"NULL\""`
String *string ` @String`
Int *int64 ` | @Int`
Float *float64 ` | @Float`
Boolean *bool ` | @("true" | "false")`
Null bool ` | @"NULL"`
}

type PseudoClass struct {
Type string `parser:"\":\" @(\"nth_child\")"`
Value *Value `parser:"\"(\" @@* \")\""`
Type string `":" @("nth_child")`
Value *Value `"(" @@* ")"`
}

func CreateParser() (*participle.Parser, error) {
Expand Down

0 comments on commit 423f5a0

Please sign in to comment.