Skip to content

Commit

Permalink
Privatized error message formats
Browse files Browse the repository at this point in the history
  • Loading branch information
Knetic committed May 1, 2017
1 parent eafdb25 commit 5722010
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions evaluationStage.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
)

const (
TYPEERROR_LOGICAL string = "Value '%v' cannot be used with the logical operator '%v', it is not a bool"
TYPEERROR_MODIFIER string = "Value '%v' cannot be used with the modifier '%v', it is not a number"
TYPEERROR_COMPARATOR string = "Value '%v' cannot be used with the comparator '%v', it is not a number"
TYPEERROR_TERNARY string = "Value '%v' cannot be used with the ternary operator '%v', it is not a bool"
TYPEERROR_PREFIX string = "Value '%v' cannot be used with the prefix '%v'"
logicalErrorFormat string = "Value '%v' cannot be used with the logical operator '%v', it is not a bool"
modifierErrorFormat string = "Value '%v' cannot be used with the modifier '%v', it is not a number"
comparatorErrorFormat string = "Value '%v' cannot be used with the comparator '%v', it is not a number"
ternaryErrorFormat string = "Value '%v' cannot be used with the ternary operator '%v', it is not a bool"
prefixErrorFormat string = "Value '%v' cannot be used with the prefix '%v'"
)

type evaluationOperator func(left interface{}, right interface{}, parameters Parameters) (interface{}, error)
Expand Down
20 changes: 10 additions & 10 deletions stagePlanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,61 +80,61 @@ func init() {
planPrefix = makePrecedentFromPlanner(&precedencePlanner{
validSymbols: PREFIX_SYMBOLS,
validKinds: []TokenKind{PREFIX},
typeErrorFormat: TYPEERROR_PREFIX,
typeErrorFormat: prefixErrorFormat,
nextRight: planFunction,
})
planExponential = makePrecedentFromPlanner(&precedencePlanner{
validSymbols: EXPONENTIAL_SYMBOLS,
validKinds: []TokenKind{MODIFIER},
typeErrorFormat: TYPEERROR_MODIFIER,
typeErrorFormat: modifierErrorFormat,
next: planFunction,
})
planMultiplicative = makePrecedentFromPlanner(&precedencePlanner{
validSymbols: MULTIPLICATIVE_SYMBOLS,
validKinds: []TokenKind{MODIFIER},
typeErrorFormat: TYPEERROR_MODIFIER,
typeErrorFormat: modifierErrorFormat,
next: planExponential,
})
planAdditive = makePrecedentFromPlanner(&precedencePlanner{
validSymbols: ADDITIVE_SYMBOLS,
validKinds: []TokenKind{MODIFIER},
typeErrorFormat: TYPEERROR_MODIFIER,
typeErrorFormat: modifierErrorFormat,
next: planMultiplicative,
})
planShift = makePrecedentFromPlanner(&precedencePlanner{
validSymbols: BITWISE_SHIFT_SYMBOLS,
validKinds: []TokenKind{MODIFIER},
typeErrorFormat: TYPEERROR_MODIFIER,
typeErrorFormat: modifierErrorFormat,
next: planAdditive,
})
planBitwise = makePrecedentFromPlanner(&precedencePlanner{
validSymbols: BITWISE_SYMBOLS,
validKinds: []TokenKind{MODIFIER},
typeErrorFormat: TYPEERROR_MODIFIER,
typeErrorFormat: modifierErrorFormat,
next: planShift,
})
planComparator = makePrecedentFromPlanner(&precedencePlanner{
validSymbols: COMPARATOR_SYMBOLS,
validKinds: []TokenKind{COMPARATOR},
typeErrorFormat: TYPEERROR_COMPARATOR,
typeErrorFormat: comparatorErrorFormat,
next: planBitwise,
})
planLogicalAnd = makePrecedentFromPlanner(&precedencePlanner{
validSymbols: map[string]OperatorSymbol{"&&": AND},
validKinds: []TokenKind{LOGICALOP},
typeErrorFormat: TYPEERROR_LOGICAL,
typeErrorFormat: logicalErrorFormat,
next: planComparator,
})
planLogicalOr = makePrecedentFromPlanner(&precedencePlanner{
validSymbols: map[string]OperatorSymbol{"||": OR},
validKinds: []TokenKind{LOGICALOP},
typeErrorFormat: TYPEERROR_LOGICAL,
typeErrorFormat: logicalErrorFormat,
next: planLogicalAnd,
})
planTernary = makePrecedentFromPlanner(&precedencePlanner{
validSymbols: TERNARY_SYMBOLS,
validKinds: []TokenKind{TERNARY},
typeErrorFormat: TYPEERROR_TERNARY,
typeErrorFormat: ternaryErrorFormat,
next: planLogicalOr,
})
planSeparator = makePrecedentFromPlanner(&precedencePlanner{
Expand Down

0 comments on commit 5722010

Please sign in to comment.