Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More dead code removal #905

Merged
merged 1 commit into from
Jan 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions internal/pkg/bifs/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion internal/pkg/dsl/ast_print.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ func (node *ASTNode) Text() string {
return tokenText
case NodeTypeEprintStatement:
return tokenText
return tokenText
case NodeTypePrintnStatement:
return tokenText
case NodeTypeEprintnStatement:
Expand Down
1 change: 0 additions & 1 deletion internal/pkg/dsl/cst/for.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 0 additions & 31 deletions internal/pkg/dsl/cst/leaves.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 "(..)_(...)"
Expand All @@ -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
Expand All @@ -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))
Expand Down Expand Up @@ -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

}

Expand Down Expand Up @@ -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

}

Expand Down
14 changes: 0 additions & 14 deletions internal/pkg/dsl/cst/lvalues.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 0 additions & 8 deletions internal/pkg/lib/halfpipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
6 changes: 0 additions & 6 deletions internal/pkg/mlrval/mlrval_cmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
9 changes: 0 additions & 9 deletions internal/pkg/mlrval/mlrval_infer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 0 additions & 8 deletions internal/pkg/transformers/bar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 0 additions & 20 deletions internal/pkg/transformers/split.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
41 changes: 0 additions & 41 deletions internal/pkg/transformers/utils/join_bucket_keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}