Skip to content

Commit

Permalink
revert parser changes
Browse files Browse the repository at this point in the history
  • Loading branch information
parametalol committed Jan 16, 2024
1 parent cb306e4 commit e6da879
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions pkg/services/queryparser/query_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/pkg/errors"
)

var validColumns = []string{"region", "name", "cloud_provider", "status", "owner", "traits"}
var validColumns = []string{"region", "name", "cloud_provider", "status", "owner"}

// BraceTokenFamily ...
const (
Expand All @@ -29,8 +29,6 @@ const (
LikeState = "LIKE"
AndState = "AND"
OrState = "OR"
AnyState = "ANY"
AllState = "ALL"
)

// MaximumComplexity ...
Expand Down Expand Up @@ -69,23 +67,19 @@ var _ QueryParser = &queryParser{}
// LIKE = [Ll][Ii][Kk][Ee]
// AND = [Aa][Nn][Dd]
// OR = [Oo][Rr]
// ANY = [Aa][Nn][Yy]
// ALL = [Aa][Ll][Ll]
//
// VALID TRANSITIONS:
// START -> COLUMN | OPEN_BRACE | VALUE
// START -> COLUMN | OPEN_BRACE
// OPEN_BRACE -> OPEN_BRACE | COLUMN
// COLUMN -> EQ | NOT_EQ | LIKE
// EQ -> VALUE | QUOTED_VALUE | ANY | ALL
// NOT_EQ -> VALUE | QUOTED_VALUE | ANY | ALL
// EQ -> VALUE | QUOTED_VALUE
// NOT_EQ -> VALUE | QUOTED_VALUE
// LIKE -> VALUE | QUOTED_VALUE
// VALUE -> OR | AND | CLOSED_BRACE | [END]
// QUOTED_VALUE -> OR | AND | CLOSED_BRACE | [END]
// CLOSED_BRACE -> OR | AND | CLOSED_BRACE | [END]
// AND -> COLUMN | OPEN_BRACE
// OR -> COLUMN | OPEN_BRACE
// ANY -> OPEN_BRACE
// ALL -> OPEN_BRACE
func (p *queryParser) initStateMachine() (State, checkUnbalancedBraces) {

// counts the number of joins
Expand Down Expand Up @@ -170,8 +164,6 @@ func (p *queryParser) initStateMachine() (State, checkUnbalancedBraces) {
{Name: LikeState, Family: OpTokenFamily, AcceptPattern: `[Ll][Ii][Kk][Ee]`},
{Name: AndState, Family: LogicalOpTokenFamily, AcceptPattern: `[Aa][Nn][Dd]`},
{Name: OrState, Family: LogicalOpTokenFamily, AcceptPattern: `[Oo][Rr]`},
{Name: AnyState, Family: LogicalOpTokenFamily, AcceptPattern: `[Aa][Nn][Yy]`},
{Name: AllState, Family: LogicalOpTokenFamily, AcceptPattern: `[Aa][Ll][Ll]`},
},
Transitions: []TransitionDefinition{
{TokenName: StartState, ValidTransitions: []string{Column, OpenBrace}},
Expand All @@ -185,8 +177,6 @@ func (p *queryParser) initStateMachine() (State, checkUnbalancedBraces) {
{TokenName: ClosedBrace, ValidTransitions: []string{OrState, AndState, ClosedBrace, EndState}},
{TokenName: AndState, ValidTransitions: []string{Column, OpenBrace}},
{TokenName: OrState, ValidTransitions: []string{Column, OpenBrace}},
{TokenName: AnyState, ValidTransitions: []string{OpenBrace}},
{TokenName: AllState, ValidTransitions: []string{OpenBrace}},
},
}

Expand Down

0 comments on commit e6da879

Please sign in to comment.