mirror of
https://github.com/johnkerl/miller.git
synced 2026-01-23 02:14:13 +00:00
Specify constant types except with iota (#884)
Constant types need to be repeated, unless iota is used or the constants are declared in the same expression (const A, B, C Type = 1, 2, 3). See https://go.dev/ref/spec#Constant_declarations for details. Signed-off-by: Stephen Kitt <steve@sk2.org>
This commit is contained in:
parent
bc8ad1b579
commit
521215992d
4 changed files with 94 additions and 94 deletions
|
|
@ -25,106 +25,106 @@ type TNodeType string
|
|||
|
||||
const (
|
||||
NodeTypeStringLiteral TNodeType = "string literal"
|
||||
NodeTypeRegex = "regular expression" // not in the BNF -- written during CST pre-build pass
|
||||
NodeTypeRegexCaseInsensitive = "case-insensitive regular expression" // E.g. "a.*b"i -- note the trailing 'i'
|
||||
NodeTypeIntLiteral = "int literal"
|
||||
NodeTypeFloatLiteral = "float literal"
|
||||
NodeTypeBoolLiteral = "bool literal"
|
||||
NodeTypeNullLiteral = "null literal"
|
||||
NodeTypeArrayLiteral = "array literal"
|
||||
NodeTypeMapLiteral = "map literal"
|
||||
NodeTypeMapLiteralKeyValuePair = "map-literal key-value pair"
|
||||
NodeTypeArrayOrMapIndexAccess = "array or map index access"
|
||||
NodeTypeArraySliceAccess = "array-slice access"
|
||||
NodeTypeArraySliceEmptyLowerIndex = "array-slice empty lower index"
|
||||
NodeTypeArraySliceEmptyUpperIndex = "array-slice empty upper index"
|
||||
NodeTypeRegex TNodeType = "regular expression" // not in the BNF -- written during CST pre-build pass
|
||||
NodeTypeRegexCaseInsensitive TNodeType = "case-insensitive regular expression" // E.g. "a.*b"i -- note the trailing 'i'
|
||||
NodeTypeIntLiteral TNodeType = "int literal"
|
||||
NodeTypeFloatLiteral TNodeType = "float literal"
|
||||
NodeTypeBoolLiteral TNodeType = "bool literal"
|
||||
NodeTypeNullLiteral TNodeType = "null literal"
|
||||
NodeTypeArrayLiteral TNodeType = "array literal"
|
||||
NodeTypeMapLiteral TNodeType = "map literal"
|
||||
NodeTypeMapLiteralKeyValuePair TNodeType = "map-literal key-value pair"
|
||||
NodeTypeArrayOrMapIndexAccess TNodeType = "array or map index access"
|
||||
NodeTypeArraySliceAccess TNodeType = "array-slice access"
|
||||
NodeTypeArraySliceEmptyLowerIndex TNodeType = "array-slice empty lower index"
|
||||
NodeTypeArraySliceEmptyUpperIndex TNodeType = "array-slice empty upper index"
|
||||
|
||||
NodeTypePositionalFieldName = "positionally-indexed field name"
|
||||
NodeTypePositionalFieldValue = "positionally-indexed field value"
|
||||
NodeTypeArrayOrMapPositionalNameAccess = "positionally-indexed map key"
|
||||
NodeTypeArrayOrMapPositionalValueAccess = "positionally-indexed map value"
|
||||
NodeTypePositionalFieldName TNodeType = "positionally-indexed field name"
|
||||
NodeTypePositionalFieldValue TNodeType = "positionally-indexed field value"
|
||||
NodeTypeArrayOrMapPositionalNameAccess TNodeType = "positionally-indexed map key"
|
||||
NodeTypeArrayOrMapPositionalValueAccess TNodeType = "positionally-indexed map value"
|
||||
|
||||
NodeTypeContextVariable = "context variable"
|
||||
NodeTypeConstant = "mathematical constant"
|
||||
NodeTypeEnvironmentVariable = "environment variable"
|
||||
NodeTypeContextVariable TNodeType = "context variable"
|
||||
NodeTypeConstant TNodeType = "mathematical constant"
|
||||
NodeTypeEnvironmentVariable TNodeType = "environment variable"
|
||||
|
||||
NodeTypeDirectFieldValue = "direct field value"
|
||||
NodeTypeIndirectFieldValue = "indirect field value"
|
||||
NodeTypeFullSrec = "full record"
|
||||
NodeTypeDirectOosvarValue = "direct oosvar value"
|
||||
NodeTypeIndirectOosvarValue = "indirect oosvar value"
|
||||
NodeTypeFullOosvar = "full oosvar"
|
||||
NodeTypeLocalVariable = "local variable"
|
||||
NodeTypeTypedecl = "type declaration"
|
||||
NodeTypeDirectFieldValue TNodeType = "direct field value"
|
||||
NodeTypeIndirectFieldValue TNodeType = "indirect field value"
|
||||
NodeTypeFullSrec TNodeType = "full record"
|
||||
NodeTypeDirectOosvarValue TNodeType = "direct oosvar value"
|
||||
NodeTypeIndirectOosvarValue TNodeType = "indirect oosvar value"
|
||||
NodeTypeFullOosvar TNodeType = "full oosvar"
|
||||
NodeTypeLocalVariable TNodeType = "local variable"
|
||||
NodeTypeTypedecl TNodeType = "type declaration"
|
||||
|
||||
NodeTypeStatementBlock = "statement block"
|
||||
NodeTypeAssignment = "assignment"
|
||||
NodeTypeUnset = "unset"
|
||||
NodeTypeStatementBlock TNodeType = "statement block"
|
||||
NodeTypeAssignment TNodeType = "assignment"
|
||||
NodeTypeUnset TNodeType = "unset"
|
||||
|
||||
NodeTypeBareBoolean = "bare boolean"
|
||||
NodeTypeFilterStatement = "filter statement"
|
||||
NodeTypeBareBoolean TNodeType = "bare boolean"
|
||||
NodeTypeFilterStatement TNodeType = "filter statement"
|
||||
|
||||
NodeTypeTeeStatement = "tee statement"
|
||||
NodeTypeEmit1Statement = "emit1 statement"
|
||||
NodeTypeEmitStatement = "emit statement"
|
||||
NodeTypeEmitPStatement = "emitp statement"
|
||||
NodeTypeEmitFStatement = "emitf statement"
|
||||
NodeTypeEmittableList = "emittable list"
|
||||
NodeTypeEmitKeys = "emit keys"
|
||||
NodeTypeDumpStatement = "dump statement"
|
||||
NodeTypeEdumpStatement = "edump statement"
|
||||
NodeTypePrintStatement = "print statement"
|
||||
NodeTypeEprintStatement = "eprint statement"
|
||||
NodeTypePrintnStatement = "printn statement"
|
||||
NodeTypeEprintnStatement = "eprintn statement"
|
||||
NodeTypeTeeStatement TNodeType = "tee statement"
|
||||
NodeTypeEmit1Statement TNodeType = "emit1 statement"
|
||||
NodeTypeEmitStatement TNodeType = "emit statement"
|
||||
NodeTypeEmitPStatement TNodeType = "emitp statement"
|
||||
NodeTypeEmitFStatement TNodeType = "emitf statement"
|
||||
NodeTypeEmittableList TNodeType = "emittable list"
|
||||
NodeTypeEmitKeys TNodeType = "emit keys"
|
||||
NodeTypeDumpStatement TNodeType = "dump statement"
|
||||
NodeTypeEdumpStatement TNodeType = "edump statement"
|
||||
NodeTypePrintStatement TNodeType = "print statement"
|
||||
NodeTypeEprintStatement TNodeType = "eprint statement"
|
||||
NodeTypePrintnStatement TNodeType = "printn statement"
|
||||
NodeTypeEprintnStatement TNodeType = "eprintn statement"
|
||||
|
||||
// For 'print > filename, "string"' et al.
|
||||
NodeTypeRedirectWrite = "redirect write"
|
||||
NodeTypeRedirectAppend = "redirect append"
|
||||
NodeTypeRedirectPipe = "redirect pipe"
|
||||
NodeTypeRedirectTargetStdout = "stdout redirect target"
|
||||
NodeTypeRedirectTargetStderr = "stderr redirect target"
|
||||
NodeTypeRedirectTarget = "redirect target"
|
||||
NodeTypeRedirectWrite TNodeType = "redirect write"
|
||||
NodeTypeRedirectAppend TNodeType = "redirect append"
|
||||
NodeTypeRedirectPipe TNodeType = "redirect pipe"
|
||||
NodeTypeRedirectTargetStdout TNodeType = "stdout redirect target"
|
||||
NodeTypeRedirectTargetStderr TNodeType = "stderr redirect target"
|
||||
NodeTypeRedirectTarget TNodeType = "redirect target"
|
||||
|
||||
// This helps various emit-variant sub-ASTs have the same shape. For
|
||||
// example, in 'emit > "foo.txt", @v' and 'emit @v', the latter has a no-op
|
||||
// for its redirect target.
|
||||
NodeTypeNoOp = "no-op"
|
||||
NodeTypeNoOp TNodeType = "no-op"
|
||||
|
||||
// The dot operator is a little different from other operators since it's
|
||||
// type-dependent: for strings/int/bools etc it's just concatenation of
|
||||
// string representations, but if the left-hand side is a map, it's a
|
||||
// key-lookup with an unquoted literal on the right. E.g. mymap.foo is the
|
||||
// same as mymap["foo"].
|
||||
NodeTypeOperator = "operator"
|
||||
NodeTypeDotOperator = "dot operator"
|
||||
NodeTypeFunctionCallsite = "function callsite"
|
||||
NodeTypeSubroutineCallsite = "subroutine callsite"
|
||||
NodeTypeOperator TNodeType = "operator"
|
||||
NodeTypeDotOperator TNodeType = "dot operator"
|
||||
NodeTypeFunctionCallsite TNodeType = "function callsite"
|
||||
NodeTypeSubroutineCallsite TNodeType = "subroutine callsite"
|
||||
|
||||
NodeTypeBeginBlock = "begin block"
|
||||
NodeTypeEndBlock = "end block"
|
||||
NodeTypeIfChain = "if-chain"
|
||||
NodeTypeIfItem = "if-item"
|
||||
NodeTypeCondBlock = "cond block"
|
||||
NodeTypeWhileLoop = "while loop"
|
||||
NodeTypeDoWhileLoop = "do-while`loop"
|
||||
NodeTypeForLoopOneVariable = "single-variable for-loop"
|
||||
NodeTypeForLoopTwoVariable = "double-variable for-loop"
|
||||
NodeTypeForLoopMultivariable = "multi-variable for-loop"
|
||||
NodeTypeTripleForLoop = "triple-for loop"
|
||||
NodeTypeBreak = "break"
|
||||
NodeTypeContinue = "continue"
|
||||
NodeTypeBeginBlock TNodeType = "begin block"
|
||||
NodeTypeEndBlock TNodeType = "end block"
|
||||
NodeTypeIfChain TNodeType = "if-chain"
|
||||
NodeTypeIfItem TNodeType = "if-item"
|
||||
NodeTypeCondBlock TNodeType = "cond block"
|
||||
NodeTypeWhileLoop TNodeType = "while loop"
|
||||
NodeTypeDoWhileLoop TNodeType = "do-while`loop"
|
||||
NodeTypeForLoopOneVariable TNodeType = "single-variable for-loop"
|
||||
NodeTypeForLoopTwoVariable TNodeType = "double-variable for-loop"
|
||||
NodeTypeForLoopMultivariable TNodeType = "multi-variable for-loop"
|
||||
NodeTypeTripleForLoop TNodeType = "triple-for loop"
|
||||
NodeTypeBreak TNodeType = "break"
|
||||
NodeTypeContinue TNodeType = "continue"
|
||||
|
||||
NodeTypeNamedFunctionDefinition = "function definition"
|
||||
NodeTypeUnnamedFunctionDefinition = "function literal"
|
||||
NodeTypeSubroutineDefinition = "subroutine definition"
|
||||
NodeTypeParameterList = "parameter list"
|
||||
NodeTypeParameter = "parameter"
|
||||
NodeTypeParameterName = "parameter name"
|
||||
NodeTypeReturn = "return"
|
||||
NodeTypeNamedFunctionDefinition TNodeType = "function definition"
|
||||
NodeTypeUnnamedFunctionDefinition TNodeType = "function literal"
|
||||
NodeTypeSubroutineDefinition TNodeType = "subroutine definition"
|
||||
NodeTypeParameterList TNodeType = "parameter list"
|
||||
NodeTypeParameter TNodeType = "parameter"
|
||||
NodeTypeParameterName TNodeType = "parameter name"
|
||||
NodeTypeReturn TNodeType = "return"
|
||||
|
||||
// A special token which causes a panic when evaluated. This is for
|
||||
// testing that AND/OR short-circuiting is implemented correctly: output =
|
||||
// input1 || panic should NOT panic the process when input1 is true.
|
||||
NodeTypePanic = "panic token"
|
||||
NodeTypePanic TNodeType = "panic token"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -28,16 +28,16 @@ type TFunctionClass string
|
|||
|
||||
const (
|
||||
FUNC_CLASS_ARITHMETIC TFunctionClass = "arithmetic"
|
||||
FUNC_CLASS_MATH = "math"
|
||||
FUNC_CLASS_BOOLEAN = "boolean"
|
||||
FUNC_CLASS_STRING = "string"
|
||||
FUNC_CLASS_HASHING = "hashing"
|
||||
FUNC_CLASS_CONVERSION = "conversion"
|
||||
FUNC_CLASS_TYPING = "typing"
|
||||
FUNC_CLASS_COLLECTIONS = "collections"
|
||||
FUNC_CLASS_HOFS = "higher-order-functions"
|
||||
FUNC_CLASS_SYSTEM = "system"
|
||||
FUNC_CLASS_TIME = "time"
|
||||
FUNC_CLASS_MATH TFunctionClass = "math"
|
||||
FUNC_CLASS_BOOLEAN TFunctionClass = "boolean"
|
||||
FUNC_CLASS_STRING TFunctionClass = "string"
|
||||
FUNC_CLASS_HASHING TFunctionClass = "hashing"
|
||||
FUNC_CLASS_CONVERSION TFunctionClass = "conversion"
|
||||
FUNC_CLASS_TYPING TFunctionClass = "typing"
|
||||
FUNC_CLASS_COLLECTIONS TFunctionClass = "collections"
|
||||
FUNC_CLASS_HOFS TFunctionClass = "higher-order-functions"
|
||||
FUNC_CLASS_SYSTEM TFunctionClass = "system"
|
||||
FUNC_CLASS_TIME TFunctionClass = "time"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
|
|
|
|||
|
|
@ -562,9 +562,9 @@ func SortHOF(
|
|||
type tSortType int
|
||||
|
||||
const (
|
||||
sortTypeLexical tSortType = 1
|
||||
sortTypeCaseFold = 2
|
||||
sortTypeNumerical = 3
|
||||
sortTypeLexical tSortType = iota
|
||||
sortTypeCaseFold
|
||||
sortTypeNumerical
|
||||
)
|
||||
|
||||
// decodeSortFlags maps strings like "cr" in the second argument to sort
|
||||
|
|
|
|||
|
|
@ -110,9 +110,9 @@ type BlockExitStatus int
|
|||
const (
|
||||
// BLOCK_EXIT_RUN_TO_END is implemented as *BlockExitPayload being nil
|
||||
BLOCK_EXIT_BREAK BlockExitStatus = 1
|
||||
BLOCK_EXIT_CONTINUE = 2
|
||||
BLOCK_EXIT_RETURN_VOID = 3
|
||||
BLOCK_EXIT_RETURN_VALUE = 4
|
||||
BLOCK_EXIT_CONTINUE BlockExitStatus = 2
|
||||
BLOCK_EXIT_RETURN_VOID BlockExitStatus = 3
|
||||
BLOCK_EXIT_RETURN_VALUE BlockExitStatus = 4
|
||||
)
|
||||
|
||||
type BlockExitPayload struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue