feat: add molang package
1. upgrade bukkit chat 2. fix config update error Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
21
packages/molang/src/parser/parselets/andOperator.ts
Normal file
21
packages/molang/src/parser/parselets/andOperator.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Parser } from '../parse'
|
||||
import { Token } from '../../tokenizer/token'
|
||||
import { IExpression } from '../expression'
|
||||
import { GenericOperatorExpression } from '../expressions/genericOperator'
|
||||
import { IInfixParselet } from './infix'
|
||||
|
||||
export class AndOperator implements IInfixParselet {
|
||||
constructor(public precedence = 0) {}
|
||||
|
||||
parse(parser: Parser, leftExpression: IExpression, token: Token) {
|
||||
if (parser.match('AND'))
|
||||
return new GenericOperatorExpression(
|
||||
leftExpression,
|
||||
parser.parseExpression(this.precedence),
|
||||
'&&',
|
||||
(leftExpression: IExpression, rightExpression: IExpression) =>
|
||||
leftExpression.eval() && rightExpression.eval()
|
||||
)
|
||||
else throw new Error(`"&" not followed by another "&"`)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user