grammar: add '<<' shift-left safely (Phase 1); map to AST/MIR/VM; keep '>>' as legacy ARROW
- Tokenizer: add SHIFT_LEFT for '<<' (before <= detection) - Parser: introduce parse_shift() layer; left-associative; only '<<' handled in Phase 1 - AST: add BinaryOperator::Shl and display - MIR builder: map Shl -> BinaryOp::Shl - Interpreter: implement Shl in both execution paths (integer-only, type error otherwise) No change to '>>' (legacy ARROW remains). No runtime gate yet for SHL as it does not collide with existing syntax.
This commit is contained in:
@ -59,6 +59,7 @@ pub enum TokenType {
|
||||
|
||||
// 演算子 (長いものから先に定義)
|
||||
ARROW, // >> (legacy arrow)
|
||||
SHIFT_LEFT, // << (bitwise shift-left)
|
||||
FAT_ARROW, // => (peek arms)
|
||||
EQUALS, // ==
|
||||
NotEquals, // !=
|
||||
@ -269,6 +270,12 @@ impl NyashTokenizer {
|
||||
self.advance();
|
||||
Ok(Token::new(TokenType::NotEquals, start_line, start_column))
|
||||
}
|
||||
// Shift-left must be detected before <= and <
|
||||
Some('<') if self.peek_char() == Some('<') => {
|
||||
self.advance();
|
||||
self.advance();
|
||||
Ok(Token::new(TokenType::SHIFT_LEFT, start_line, start_column))
|
||||
}
|
||||
Some('<') if self.peek_char() == Some('=') => {
|
||||
self.advance();
|
||||
self.advance();
|
||||
|
||||
Reference in New Issue
Block a user