mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-20 06:50:47 -07:00
feat: support not operator, #575
This commit is contained in:
@@ -1,18 +1,37 @@
|
||||
import { Token } from './token'
|
||||
import { TokenKind } from '../parser'
|
||||
|
||||
export const precedence = {
|
||||
'==': 1,
|
||||
'!=': 1,
|
||||
'>': 1,
|
||||
'<': 1,
|
||||
'>=': 1,
|
||||
'<=': 1,
|
||||
'contains': 1,
|
||||
export const enum OperatorType {
|
||||
Binary,
|
||||
Unary
|
||||
}
|
||||
|
||||
export const operatorPrecedences = {
|
||||
'==': 2,
|
||||
'!=': 2,
|
||||
'>': 2,
|
||||
'<': 2,
|
||||
'>=': 2,
|
||||
'<=': 2,
|
||||
'contains': 2,
|
||||
'not': 1,
|
||||
'and': 0,
|
||||
'or': 0
|
||||
}
|
||||
|
||||
export const operatorTypes = {
|
||||
'==': OperatorType.Binary,
|
||||
'!=': OperatorType.Binary,
|
||||
'>': OperatorType.Binary,
|
||||
'<': OperatorType.Binary,
|
||||
'>=': OperatorType.Binary,
|
||||
'<=': OperatorType.Binary,
|
||||
'contains': OperatorType.Binary,
|
||||
'not': OperatorType.Unary,
|
||||
'and': OperatorType.Binary,
|
||||
'or': OperatorType.Binary
|
||||
}
|
||||
|
||||
export class OperatorToken extends Token {
|
||||
public operator: string
|
||||
public constructor (
|
||||
@@ -26,6 +45,6 @@ export class OperatorToken extends Token {
|
||||
}
|
||||
getPrecedence () {
|
||||
const key = this.getText()
|
||||
return key in precedence ? precedence[key] : 1
|
||||
return key in operatorPrecedences ? operatorPrecedences[key] : 1
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user