From 2e9e966f0b61e5285ede3df83c9e4f7466a48701 Mon Sep 17 00:00:00 2001 From: otya128 Date: Tue, 9 Jun 2015 21:27:31 +0900 Subject: [PATCH] =?UTF-8?q?=E6=BC=94=E7=AE=97=E9=A0=86=E4=BD=8D=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SMILEBASIC/main.d | 3 +++ SMILEBASIC/parser.d | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/SMILEBASIC/main.d b/SMILEBASIC/main.d index 01daf37..85d210b 100644 --- a/SMILEBASIC/main.d +++ b/SMILEBASIC/main.d @@ -44,6 +44,9 @@ FOR I=0 TO 100 ENDIF ENDIF NEXT +?1 AND 1 OR 1 AND 0 +?(1 OR 2 XOR 3) +?(1 OR 2 XOR 3 OR 4) ?@HELLOWORLD GOSUB @A END diff --git a/SMILEBASIC/parser.d b/SMILEBASIC/parser.d index 3c72bc5..fd4429b 100644 --- a/SMILEBASIC/parser.d +++ b/SMILEBASIC/parser.d @@ -278,10 +278,13 @@ class Parser this.code = input; lex = new Lexical(input); } + const int opMax = 11; int getOPRank(TokenType type) { switch(type) { + version(none) + { case TokenType.LogicalAnd: case TokenType.LogicalOr: return 8;//&&,|| @@ -289,6 +292,17 @@ class Parser case TokenType.Or: case TokenType.Xor: return 7;//AND,OR,XOR + } + case TokenType.LogicalAnd: + return 10;//&&,|| + case TokenType.LogicalOr: + return 11;//&&,|| + case TokenType.And: + return 7;//AND,OR,XOR + case TokenType.Or: + return 9-1;//AND,OR,XOR + case TokenType.Xor: + return 9;//AND,OR,XOR case TokenType.Equal: case TokenType.NotEqual: case TokenType.Less: @@ -684,7 +698,7 @@ class Parser Expression expression() { Expression node = null; - return term(8, node); + return term(opMax, node); } Expression term(int order, Expression node) {