1
0
mirror of https://github.com/taigrr/yq synced 2025-01-18 04:53:17 -08:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Mike Farah
5911ab2929 Bump version 2021-02-25 16:52:49 +11:00
Mike Farah
2ed5b2ff59 Improved lexer performance! 2021-02-25 16:47:55 +11:00
5 changed files with 9 additions and 10 deletions

View File

@@ -11,7 +11,7 @@ var (
GitDescribe string GitDescribe string
// Version is main version number that is being run at the moment. // Version is main version number that is being run at the moment.
Version = "4.6.0" Version = "4.6.1"
// VersionPrerelease is a pre-release marker for the version. If this is "" (empty string) // VersionPrerelease is a pre-release marker for the version. If this is "" (empty string)
// then it means that it is a final release. Otherwise, this is a pre-release // then it means that it is a final release. Otherwise, this is a pre-release

View File

@@ -1,4 +1,4 @@
FROM mikefarah/yq:4.6.0 FROM mikefarah/yq:4.6.1
COPY entrypoint.sh /entrypoint.sh COPY entrypoint.sh /entrypoint.sh

View File

@@ -5,9 +5,6 @@ import (
"strings" "strings"
) )
var myPathTokeniser = newExpressionTokeniser()
var myPathPostfixer = newExpressionPostFixer()
type ExpressionNode struct { type ExpressionNode struct {
Operation *Operation Operation *Operation
Lhs *ExpressionNode Lhs *ExpressionNode
@@ -19,19 +16,21 @@ type ExpressionParser interface {
} }
type expressionParserImpl struct { type expressionParserImpl struct {
pathTokeniser expressionTokeniser
pathPostFixer expressionPostFixer
} }
func NewExpressionParser() ExpressionParser { func NewExpressionParser() ExpressionParser {
return &expressionParserImpl{} return &expressionParserImpl{newExpressionTokeniser(), newExpressionPostFixer()}
} }
func (p *expressionParserImpl) ParseExpression(expression string) (*ExpressionNode, error) { func (p *expressionParserImpl) ParseExpression(expression string) (*ExpressionNode, error) {
tokens, err := myPathTokeniser.Tokenise(expression) tokens, err := p.pathTokeniser.Tokenise(expression)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var Operations []*Operation var Operations []*Operation
Operations, err = myPathPostfixer.ConvertToPostfix(tokens) Operations, err = p.pathPostFixer.ConvertToPostfix(tokens)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -328,7 +328,7 @@ func initLexer() (*lex.Lexer, error) {
lexer.Add([]byte(`\$[a-zA-Z_-0-9]+`), getVariableOpToken()) lexer.Add([]byte(`\$[a-zA-Z_-0-9]+`), getVariableOpToken())
lexer.Add([]byte(`as`), opToken(assignVariableOpType)) lexer.Add([]byte(`as`), opToken(assignVariableOpType))
err := lexer.Compile() err := lexer.CompileNFA()
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -1,5 +1,5 @@
name: yq name: yq
version: '4.6.0' version: '4.6.1'
summary: A lightweight and portable command-line YAML processor summary: A lightweight and portable command-line YAML processor
description: | description: |
The aim of the project is to be the jq or sed of yaml files. The aim of the project is to be the jq or sed of yaml files.