Improved visibility of token groups
This commit is contained in:
parent
bc8e7e452d
commit
e62eaba6e6
@ -19,7 +19,7 @@ const (
|
|||||||
ArrayStart // [
|
ArrayStart // [
|
||||||
ArrayEnd // ]
|
ArrayEnd // ]
|
||||||
ReturnType // ->
|
ReturnType // ->
|
||||||
_operators // <operators>
|
___OPERATORS___ // <operators>
|
||||||
Add // +
|
Add // +
|
||||||
Sub // -
|
Sub // -
|
||||||
Mul // *
|
Mul // *
|
||||||
@ -32,24 +32,12 @@ const (
|
|||||||
Shr // >>
|
Shr // >>
|
||||||
LogicalAnd // &&
|
LogicalAnd // &&
|
||||||
LogicalOr // ||
|
LogicalOr // ||
|
||||||
_comparisons // <comparisons>
|
|
||||||
Equal // ==
|
|
||||||
NotEqual // !=
|
|
||||||
Less // <
|
|
||||||
Greater // >
|
|
||||||
LessEqual // <=
|
|
||||||
GreaterEqual // >=
|
|
||||||
_comparisonsEnd // </comparisons>
|
|
||||||
Define // :=
|
Define // :=
|
||||||
Period // .
|
Period // .
|
||||||
Call // x()
|
Call // x()
|
||||||
Array // [x]
|
Array // [x]
|
||||||
Separator // ,
|
Separator // ,
|
||||||
_unary // <unary>
|
___ASSIGNMENTS___ // <assignments>
|
||||||
Not // ! (unary)
|
|
||||||
Negate // - (unary)
|
|
||||||
_unaryEnd // </unary>
|
|
||||||
_assignments // <assignments>
|
|
||||||
Assign // =
|
Assign // =
|
||||||
AddAssign // +=
|
AddAssign // +=
|
||||||
SubAssign // -=
|
SubAssign // -=
|
||||||
@ -61,9 +49,21 @@ const (
|
|||||||
XorAssign // ^=
|
XorAssign // ^=
|
||||||
ShlAssign // <<=
|
ShlAssign // <<=
|
||||||
ShrAssign // >>=
|
ShrAssign // >>=
|
||||||
_assignmentsEnd // </assignments>
|
___END_ASSIGNMENTS___ // </assignments>
|
||||||
_operatorsEnd // </operators>
|
___COMPARISONS___ // <comparisons>
|
||||||
_keywords // <keywords>
|
Equal // ==
|
||||||
|
NotEqual // !=
|
||||||
|
Less // <
|
||||||
|
Greater // >
|
||||||
|
LessEqual // <=
|
||||||
|
GreaterEqual // >=
|
||||||
|
___END_COMPARISONS___ // </comparisons>
|
||||||
|
___UNARY___ // <unary>
|
||||||
|
Not // ! (unary)
|
||||||
|
Negate // - (unary)
|
||||||
|
___END_UNARY___ // </unary>
|
||||||
|
___END_OPERATORS___ // </operators>
|
||||||
|
___KEYWORDS___ // <keywords>
|
||||||
Assert // assert
|
Assert // assert
|
||||||
Else // else
|
Else // else
|
||||||
If // if
|
If // if
|
||||||
@ -71,5 +71,5 @@ const (
|
|||||||
Loop // loop
|
Loop // loop
|
||||||
Return // return
|
Return // return
|
||||||
Switch // switch
|
Switch // switch
|
||||||
_keywordsEnd // </keywords>
|
___END_KEYWORDS___ // </keywords>
|
||||||
)
|
)
|
||||||
|
@ -25,12 +25,12 @@ func (t Token) End() Position {
|
|||||||
|
|
||||||
// IsAssignment returns true if the token is an assignment operator.
|
// IsAssignment returns true if the token is an assignment operator.
|
||||||
func (t Token) IsAssignment() bool {
|
func (t Token) IsAssignment() bool {
|
||||||
return t.Kind > _assignments && t.Kind < _assignmentsEnd
|
return t.Kind > ___ASSIGNMENTS___ && t.Kind < ___END_ASSIGNMENTS___
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsComparison returns true if the token is a comparison operator.
|
// IsComparison returns true if the token is a comparison operator.
|
||||||
func (t Token) IsComparison() bool {
|
func (t Token) IsComparison() bool {
|
||||||
return t.Kind > _comparisons && t.Kind < _comparisonsEnd
|
return t.Kind > ___COMPARISONS___ && t.Kind < ___END_COMPARISONS___
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsExpressionStart returns true if the token starts an expression.
|
// IsExpressionStart returns true if the token starts an expression.
|
||||||
@ -40,7 +40,7 @@ func (t Token) IsExpressionStart() bool {
|
|||||||
|
|
||||||
// IsKeyword returns true if the token is a keyword.
|
// IsKeyword returns true if the token is a keyword.
|
||||||
func (t Token) IsKeyword() bool {
|
func (t Token) IsKeyword() bool {
|
||||||
return t.Kind > _keywords && t.Kind < _keywordsEnd
|
return t.Kind > ___KEYWORDS___ && t.Kind < ___END_KEYWORDS___
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsNumeric returns true if the token is a number or rune.
|
// IsNumeric returns true if the token is a number or rune.
|
||||||
@ -50,12 +50,12 @@ func (t Token) IsNumeric() bool {
|
|||||||
|
|
||||||
// IsOperator returns true if the token is an operator.
|
// IsOperator returns true if the token is an operator.
|
||||||
func (t Token) IsOperator() bool {
|
func (t Token) IsOperator() bool {
|
||||||
return t.Kind > _operators && t.Kind < _operatorsEnd
|
return t.Kind > ___OPERATORS___ && t.Kind < ___END_OPERATORS___
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsUnaryOperator returns true if the token is a unary operator.
|
// IsUnaryOperator returns true if the token is a unary operator.
|
||||||
func (t Token) IsUnaryOperator() bool {
|
func (t Token) IsUnaryOperator() bool {
|
||||||
return t.Kind > _unary && t.Kind < _unaryEnd
|
return t.Kind > ___UNARY___ && t.Kind < ___END_UNARY___
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset resets the token to default values.
|
// Reset resets the token to default values.
|
||||||
|
Loading…
Reference in New Issue
Block a user