Skip to content

Commit

Permalink
feat:改变了is的优先级
Browse files Browse the repository at this point in the history
  • Loading branch information
Bylx666 committed Apr 2, 2024
1 parent b954b98 commit 6a931a7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
12 changes: 1 addition & 11 deletions samples/helloworld.ks
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@

//mod samples/testmod.ks> m;

class MyVec {
a:Buf
.@index_get(i): self.a[i], // 别忘了逗号
.@index_set(i, v) {
self.a[i] = v;
}
}
let a = MyVec::{a:'233'};
let a = '233';
a[1] = 0;
log(a);
log(8u>>3==1)
24 changes: 12 additions & 12 deletions src/scan/charts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
pub const fn prec(x:&[u8])-> u8 {
match x {
b"-."|b"-:" => 16,
b"is"=> 15,
b"::"|b"." => 14,
b"("|b"[" => 13, // 代指调用和索引
// unary => 12
b"*" | b"%" | b"/" => 11,
b"+" | b"-" => 10,
b"<<"|b">>" => 9,
b"&" => 8,
b"^" => 7,
b"|" => 6,
b"=="|b"!="|b"<"|b">"|b"<="|b">=" => 5,
b"::"|b"." => 15,
b"("|b"[" => 14, // 代指调用和索引
// unary => 13
b"*" | b"%" | b"/" => 12,
b"+" | b"-" => 11,
b"<<"|b">>" => 10,
b"&" => 9,
b"^" => 8,
b"|" => 7,
b"=="|b"!="|b"<"|b">"|b"<="|b">=" => 6,
b"is"=> 5,
b"&&" => 4,
b"||" => 3,
b"="|b"+="|b"-="|b"*="|b"/="|b"%="|b"&="|b"|="|b"^="|b"<<="|b">>=" => 2,
b"|>" => 1, // 管道运算符应当最靠后计算
_=> 0
}
}
pub const PREC_UNARY:u8 = 12;
pub const PREC_UNARY:u8 = 13;


/// 转义符表
Expand Down

0 comments on commit 6a931a7

Please sign in to comment.