diff --git a/internal/pkg/bifs/base.go b/internal/pkg/bifs/base.go index 6242d34aba..914edf950a 100644 --- a/internal/pkg/bifs/base.go +++ b/internal/pkg/bifs/base.go @@ -141,11 +141,6 @@ func _void(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { return mlrval.VOID } -// Return 0 (binary) -func _zero2(input1 *mlrval.Mlrval) *mlrval.Mlrval { - return mlrval.FromInt(0) -} - // Return first argument (binary) func _1___(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { return input1 diff --git a/internal/pkg/dsl/ast_print.go b/internal/pkg/dsl/ast_print.go index fc4ec3b0b7..55dfcc78bb 100644 --- a/internal/pkg/dsl/ast_print.go +++ b/internal/pkg/dsl/ast_print.go @@ -262,7 +262,6 @@ func (node *ASTNode) Text() string { return tokenText case NodeTypeEprintStatement: return tokenText - return tokenText case NodeTypePrintnStatement: return tokenText case NodeTypeEprintnStatement: diff --git a/internal/pkg/dsl/cst/for.go b/internal/pkg/dsl/cst/for.go index 3ee5522581..256d6c69be 100644 --- a/internal/pkg/dsl/cst/for.go +++ b/internal/pkg/dsl/cst/for.go @@ -580,7 +580,6 @@ func (node *ForLoopMultivariableNode) executeOuter( if blockExitPayload != nil { if blockExitPayload.blockExitStatus == BLOCK_EXIT_BREAK { return blockExitPayload, nil - break } // If BLOCK_EXIT_CONTINUE, keep going -- this means the body was exited // early but we keep going at this level diff --git a/internal/pkg/dsl/cst/leaves.go b/internal/pkg/dsl/cst/leaves.go index 0063d59248..e8f158b37f 100644 --- a/internal/pkg/dsl/cst/leaves.go +++ b/internal/pkg/dsl/cst/leaves.go @@ -25,25 +25,19 @@ func (root *RootNode) BuildLeafNode( case dsl.NodeTypeDirectFieldValue: return root.BuildDirectFieldRvalueNode(sval), nil - break case dsl.NodeTypeFullSrec: return root.BuildFullSrecRvalueNode(), nil - break case dsl.NodeTypeDirectOosvarValue: return root.BuildDirectOosvarRvalueNode(sval), nil - break case dsl.NodeTypeFullOosvar: return root.BuildFullOosvarRvalueNode(), nil - break case dsl.NodeTypeLocalVariable: return root.BuildLocalVariableNode(sval), nil - break case dsl.NodeTypeStringLiteral: return root.BuildStringLiteralNode(sval), nil - break case dsl.NodeTypeRegex: // During the BNF parse all string literals -- "foo" or "(..)_(...)" @@ -54,7 +48,6 @@ func (root *RootNode) BuildLeafNode( // handling backslash sequences for regex literals differently from // those for non-regex string literals. return root.BuildRegexLiteralNode(sval), nil - break case dsl.NodeTypeRegexCaseInsensitive: // StringLiteral nodes like '"abc"' entered by the user come in from @@ -64,37 +57,27 @@ func (root *RootNode) BuildLeafNode( // (The alternative would be to make a separate Mlrval type separate // from string.) return root.BuildRegexLiteralNode(sval), nil - break case dsl.NodeTypeIntLiteral: return root.BuildIntLiteralNode(sval), nil - break case dsl.NodeTypeFloatLiteral: return root.BuildFloatLiteralNode(sval), nil - break case dsl.NodeTypeBoolLiteral: return root.BuildBoolLiteralNode(sval), nil - break case dsl.NodeTypeNullLiteral: return root.BuildNullLiteralNode(), nil - break case dsl.NodeTypeContextVariable: return root.BuildContextVariableNode(astNode) - break case dsl.NodeTypeConstant: return root.BuildConstantNode(astNode) - break case dsl.NodeTypeArraySliceEmptyLowerIndex: return root.BuildArraySliceEmptyLowerIndexNode(astNode) - break case dsl.NodeTypeArraySliceEmptyUpperIndex: return root.BuildArraySliceEmptyUpperIndexNode(astNode) - break case dsl.NodeTypePanic: return root.BuildPanicNode(astNode) - break } return nil, fmt.Errorf("at CST BuildLeafNode: unhandled AST node %s", string(astNode.Type)) @@ -401,43 +384,31 @@ func (root *RootNode) BuildContextVariableNode(astNode *dsl.ASTNode) (IEvaluable case "FILENAME": return root.BuildFILENAMENode(), nil - break case "FILENUM": return root.BuildFILENUMNode(), nil - break case "NF": return root.BuildNFNode(), nil - break case "NR": return root.BuildNRNode(), nil - break case "FNR": return root.BuildFNRNode(), nil - break case "IRS": return root.BuildIRSNode(), nil - break case "IFS": return root.BuildIFSNode(), nil - break case "IPS": return root.BuildIPSNode(), nil - break case "ORS": return root.BuildORSNode(), nil - break case "OFS": return root.BuildOFSNode(), nil - break case "OPS": return root.BuildOPSNode(), nil - break case "FLATSEP": return root.BuildFLATSEPNode(), nil - break } @@ -609,10 +580,8 @@ func (root *RootNode) BuildConstantNode(astNode *dsl.ASTNode) (IEvaluable, error case "M_PI": return root.BuildMathPINode(), nil - break case "M_E": return root.BuildMathENode(), nil - break } diff --git a/internal/pkg/dsl/cst/lvalues.go b/internal/pkg/dsl/cst/lvalues.go index 2e68437227..f6cb181710 100644 --- a/internal/pkg/dsl/cst/lvalues.go +++ b/internal/pkg/dsl/cst/lvalues.go @@ -24,56 +24,42 @@ func (root *RootNode) BuildAssignableNode( case dsl.NodeTypeDirectFieldValue: return root.BuildDirectFieldValueLvalueNode(astNode) - break case dsl.NodeTypeIndirectFieldValue: return root.BuildIndirectFieldValueLvalueNode(astNode) - break case dsl.NodeTypePositionalFieldName: return root.BuildPositionalFieldNameLvalueNode(astNode) - break case dsl.NodeTypePositionalFieldValue: return root.BuildPositionalFieldValueLvalueNode(astNode) - break case dsl.NodeTypeFullSrec: return root.BuildFullSrecLvalueNode(astNode) - break case dsl.NodeTypeDirectOosvarValue: return root.BuildDirectOosvarValueLvalueNode(astNode) - break case dsl.NodeTypeIndirectOosvarValue: return root.BuildIndirectOosvarValueLvalueNode(astNode) - break case dsl.NodeTypeFullOosvar: return root.BuildFullOosvarLvalueNode(astNode) - break case dsl.NodeTypeLocalVariable: return root.BuildLocalVariableLvalueNode(astNode) - break case dsl.NodeTypeArrayOrMapPositionalNameAccess: return nil, fmt.Errorf( "mlr: '[[...]]' is allowed on assignment left-hand sides only when immediately preceded by '$'.", ) - break case dsl.NodeTypeArrayOrMapPositionalValueAccess: return nil, fmt.Errorf( "mlr: '[[[...]]]' is allowed on assignment left-hand sides only when immediately preceded by '$'.", ) - break case dsl.NodeTypeArrayOrMapIndexAccess: return root.BuildIndexedLvalueNode(astNode) - break case dsl.NodeTypeDotOperator: return root.BuildIndexedLvalueNode(astNode) - break case dsl.NodeTypeEnvironmentVariable: return root.BuildEnvironmentVariableLvalueNode(astNode) - break } return nil, fmt.Errorf( diff --git a/internal/pkg/lib/halfpipe.go b/internal/pkg/lib/halfpipe.go index 57cbcd21e5..ab8eb7f11a 100644 --- a/internal/pkg/lib/halfpipe.go +++ b/internal/pkg/lib/halfpipe.go @@ -86,11 +86,3 @@ func OpenInboundHalfPipe(commandString string) (*os.File, error) { return readPipe, nil } - -func waitAndClose(process *os.Process, readPipe *os.File) { - _, err := process.Wait() - if err != nil { - fmt.Fprintf(os.Stderr, "%s: %v\n", "mlr", err) - } - readPipe.Close() -} diff --git a/internal/pkg/mlrval/mlrval_cmp.go b/internal/pkg/mlrval/mlrval_cmp.go index 7060e5fdef..9585d1b9c5 100644 --- a/internal/pkg/mlrval/mlrval_cmp.go +++ b/internal/pkg/mlrval/mlrval_cmp.go @@ -102,12 +102,6 @@ func string_cmp(a, b string) int { func cmp_b_ss(input1, input2 *Mlrval) int { return string_cmp(input1.printrep, input2.printrep) } -func cmp_b_xs(input1, input2 *Mlrval) int { - return string_cmp(input1.String(), input2.printrep) -} -func cmp_b_sx(input1, input2 *Mlrval) int { - return string_cmp(input1.printrep, input2.String()) -} func cmp_b_ii(input1, input2 *Mlrval) int { return int_cmp(input1.intval, input2.intval) } diff --git a/internal/pkg/mlrval/mlrval_infer.go b/internal/pkg/mlrval/mlrval_infer.go index d7ac548ced..dfd4c8916e 100644 --- a/internal/pkg/mlrval/mlrval_infer.go +++ b/internal/pkg/mlrval/mlrval_infer.go @@ -198,15 +198,6 @@ func inferMaybeFloat(mv *Mlrval) *Mlrval { } } -// TODO: comment -func inferFromBool(mv *Mlrval) *Mlrval { - if mv.printrep == "true" { - return mv.SetFromPrevalidatedBoolString(mv.printrep, true) - } else { - return mv.SetFromPrevalidatedBoolString(mv.printrep, false) - } -} - // TODO: comment // Shared code for 0o/0b integers func inferBaseInt(mv *Mlrval, base int) *Mlrval { diff --git a/internal/pkg/transformers/bar.go b/internal/pkg/transformers/bar.go index b1191ff764..f5417988c8 100644 --- a/internal/pkg/transformers/bar.go +++ b/internal/pkg/transformers/bar.go @@ -218,14 +218,6 @@ func (tr *TransformerBar) Transform( tr.recordTransformerFunc(inrecAndContext, outputRecordsAndContexts, inputDownstreamDoneChannel, outputDownstreamDoneChannel) } -// ---------------------------------------------------------------- -func (tr *TransformerBar) simpleBar( - inrecAndContext *types.RecordAndContext, - outputRecordsAndContexts *list.List, // list of *types.RecordAndContext -) { - outputRecordsAndContexts.PushBack(inrecAndContext) -} - // ---------------------------------------------------------------- func (tr *TransformerBar) processNoAuto( inrecAndContext *types.RecordAndContext, diff --git a/internal/pkg/transformers/split.go b/internal/pkg/transformers/split.go index b30a6637cc..fb6578f644 100644 --- a/internal/pkg/transformers/split.go +++ b/internal/pkg/transformers/split.go @@ -415,23 +415,3 @@ func (tr *TransformerSplit) makeGroupedOutputFileName( buffer.WriteString(tr.outputFileNameSuffix) return buffer.String() } - -// makeGroupedIndexedOutputFileName example: "split_yellow_53.csv" -func (tr *TransformerSplit) makeGroupedIndexedOutputFileName( - groupByFieldValues []*mlrval.Mlrval, - index int, -) string { - // URL-escape the fields which come from data and which may have '/' - // etc within. Don't URL-escape the prefix since people may want to - // use prefixes like '/tmp/split' to write to the /tmp directory, etc. - var buffer bytes.Buffer - buffer.WriteString(tr.outputFileNamePrefix) - for _, groupByFieldValue := range groupByFieldValues { - buffer.WriteString("_") - buffer.WriteString(url.QueryEscape(groupByFieldValue.String())) - } - buffer.WriteString(fmt.Sprintf("_%d", index)) - buffer.WriteString(".") - buffer.WriteString(tr.outputFileNameSuffix) - return buffer.String() -} diff --git a/internal/pkg/transformers/utils/join_bucket_keeper.go b/internal/pkg/transformers/utils/join_bucket_keeper.go index 3d0435d9a7..535479fb68 100644 --- a/internal/pkg/transformers/utils/join_bucket_keeper.go +++ b/internal/pkg/transformers/utils/join_bucket_keeper.go @@ -624,44 +624,3 @@ func compareLexically( } return 0 } - -// ================================================================ -func (keeper *JoinBucketKeeper) dump(prefix string) { - fmt.Printf("+----------------------------------------------------- %s\n", prefix) - fmt.Println("| recordReaderDone [", keeper.recordReaderDone, "]") - fmt.Println("| leof [", keeper.leof, "]") - fmt.Println("| stateCode [", keeper.state, "]") - fmt.Println("| leftJoinFieldNames [", strings.Join(keeper.leftJoinFieldNames, ","), "]") - - fmt.Println("| JoinBucket:") - // TODO: make utility method - leftFieldValuesString := make([]string, len(keeper.JoinBucket.leftFieldValues)) - for i, leftFieldValue := range keeper.JoinBucket.leftFieldValues { - leftFieldValuesString[i] = leftFieldValue.String() - } - fmt.Printf("| leftFieldValues [%s]\n", strings.Join(leftFieldValuesString, ",")) - fmt.Printf("| RecordsAndContexts (%d)\n", keeper.JoinBucket.RecordsAndContexts.Len()) - for element := keeper.JoinBucket.RecordsAndContexts.Front(); element != nil; element = element.Next() { - fmt.Println("| ", element.Value.(*types.RecordAndContext).Record.ToDKVPString()) - } - fmt.Println("| WasPaired ", keeper.JoinBucket.WasPaired) - - if keeper.peekRecordAndContext == nil || keeper.peekRecordAndContext.Record == nil { - fmt.Println("| peekRecordAndContext [nil]") - } else { - fmt.Println("| peekRecordAndContext [", keeper.peekRecordAndContext.Record.ToDKVPString(), "]") - } - - fmt.Printf("| leftUnpaireds (%d)\n", keeper.leftUnpaireds.Len()) - for element := keeper.leftUnpaireds.Front(); element != nil; element = element.Next() { - fmt.Println("| ", element.Value.(*types.RecordAndContext).Record.ToDKVPString()) - } - - fmt.Printf("------------------------------------------------------\n") -} - -func dumpFieldValues(name string, values []*mlrval.Mlrval) { - for i, value := range values { - fmt.Printf("-- %s[%d] = %s\n", name, i, value.String()) - } -}