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

Specify constant types except with iota #884

Merged
merged 1 commit into from
Jan 19, 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
172 changes: 86 additions & 86 deletions internal/pkg/dsl/ast_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

NodeTypePositionalFieldName = "positionally-indexed field name"
NodeTypePositionalFieldValue = "positionally-indexed field value"
NodeTypeArrayOrMapPositionalNameAccess = "positionally-indexed map key"
NodeTypeArrayOrMapPositionalValueAccess = "positionally-indexed map value"

NodeTypeContextVariable = "context variable"
NodeTypeConstant = "mathematical constant"
NodeTypeEnvironmentVariable = "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"

NodeTypeStatementBlock = "statement block"
NodeTypeAssignment = "assignment"
NodeTypeUnset = "unset"

NodeTypeBareBoolean = "bare boolean"
NodeTypeFilterStatement = "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"
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 TNodeType = "positionally-indexed field name"
NodeTypePositionalFieldValue TNodeType = "positionally-indexed field value"
NodeTypeArrayOrMapPositionalNameAccess TNodeType = "positionally-indexed map key"
NodeTypeArrayOrMapPositionalValueAccess TNodeType = "positionally-indexed map value"

NodeTypeContextVariable TNodeType = "context variable"
NodeTypeConstant TNodeType = "mathematical constant"
NodeTypeEnvironmentVariable TNodeType = "environment variable"

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 TNodeType = "statement block"
NodeTypeAssignment TNodeType = "assignment"
NodeTypeUnset TNodeType = "unset"

NodeTypeBareBoolean TNodeType = "bare boolean"
NodeTypeFilterStatement TNodeType = "filter 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"

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"

NodeTypeNamedFunctionDefinition = "function definition"
NodeTypeUnnamedFunctionDefinition = "function literal"
NodeTypeSubroutineDefinition = "subroutine definition"
NodeTypeParameterList = "parameter list"
NodeTypeParameter = "parameter"
NodeTypeParameterName = "parameter name"
NodeTypeReturn = "return"
NodeTypeOperator TNodeType = "operator"
NodeTypeDotOperator TNodeType = "dot operator"
NodeTypeFunctionCallsite TNodeType = "function callsite"
NodeTypeSubroutineCallsite TNodeType = "subroutine callsite"

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 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"
)
20 changes: 10 additions & 10 deletions internal/pkg/dsl/cst/builtin_function_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

// ================================================================
Expand Down
6 changes: 3 additions & 3 deletions internal/pkg/dsl/cst/hofs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions internal/pkg/dsl/cst/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down