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:
Tomoaki
2025-09-08 03:44:55 +09:00
parent 2578120b23
commit 7c2b09c647
7 changed files with 53 additions and 3 deletions

View File

@ -333,6 +333,7 @@ pub enum BinaryOperator {
Multiply,
Divide,
Modulo,
Shl, // << shift-left (Phase 1)
Equal,
NotEqual,
Less,
@ -361,6 +362,7 @@ impl fmt::Display for BinaryOperator {
BinaryOperator::Multiply => "*",
BinaryOperator::Divide => "/",
BinaryOperator::Modulo => "%",
BinaryOperator::Shl => "<<",
BinaryOperator::Equal => "==",
BinaryOperator::NotEqual => "!=",
BinaryOperator::Less => "<",