json(vm): fix birth dispatch; unify constructor naming (Box.birth/N); JsonNode factories return JsonNodeInstance; quick: enable heavy JSON with probe; builder: NYASH_BUILDER_DEBUG_LIMIT guard; json_query_min(core) harness; docs/tasks updated
This commit is contained in:
@ -157,6 +157,16 @@ impl ExprParserWithCursor {
|
||||
span: Span::new(op_line, 0, op_line, 0),
|
||||
})
|
||||
}
|
||||
TokenType::BitNot => {
|
||||
let op_line = cursor.current().line;
|
||||
cursor.advance();
|
||||
let operand = Self::parse_unary_expr(cursor)?;
|
||||
Ok(ASTNode::UnaryOp {
|
||||
operator: crate::ast::UnaryOperator::BitNot,
|
||||
operand: Box::new(operand),
|
||||
span: Span::new(op_line, 0, op_line, 0),
|
||||
})
|
||||
}
|
||||
TokenType::AWAIT => {
|
||||
let op_line = cursor.current().line;
|
||||
cursor.advance();
|
||||
|
||||
@ -222,6 +222,17 @@ impl NyashParser {
|
||||
});
|
||||
}
|
||||
|
||||
// Bitwise NOT '~'
|
||||
if self.match_token(&TokenType::BitNot) {
|
||||
self.advance(); // consume '~'
|
||||
let operand = self.parse_unary()?;
|
||||
return Ok(ASTNode::UnaryOp {
|
||||
operator: UnaryOperator::BitNot,
|
||||
operand: Box::new(operand),
|
||||
span: Span::unknown(),
|
||||
});
|
||||
}
|
||||
|
||||
if self.match_token(&TokenType::AWAIT) {
|
||||
self.advance(); // consume 'await'
|
||||
let expression = self.parse_unary()?; // 再帰的にパース
|
||||
|
||||
@ -93,7 +93,10 @@ impl NyashParser {
|
||||
self.consume(TokenType::LBRACE)?;
|
||||
let mut statements = Vec::new();
|
||||
|
||||
while !self.is_at_end() && !self.match_token(&TokenType::RBRACE) {
|
||||
// Be tolerant to blank lines within blocks: skip NEWLINE tokens between statements
|
||||
while !self.is_at_end() {
|
||||
while self.match_token(&TokenType::NEWLINE) { self.advance(); }
|
||||
if self.match_token(&TokenType::RBRACE) { break; }
|
||||
statements.push(self.parse_statement()?);
|
||||
}
|
||||
if trace_blocks {
|
||||
@ -150,7 +153,20 @@ impl NyashParser {
|
||||
}
|
||||
};
|
||||
|
||||
while !self.is_at_end() && !self.match_token(&TokenType::RBRACE) {
|
||||
while !self.is_at_end() {
|
||||
// Skip blank lines at method body top-level
|
||||
while self.match_token(&TokenType::NEWLINE) { self.advance(); }
|
||||
// Stop at end of current method body
|
||||
if self.match_token(&TokenType::RBRACE) { break; }
|
||||
// Optional seam guard: if the upcoming tokens form a method head
|
||||
// like `ident '(' ... ')' NEWLINE* '{'`, bail out so the caller
|
||||
// (static box member parser) can handle it as a declaration, not
|
||||
// as a function call expression inside this body.
|
||||
if std::env::var("NYASH_PARSER_METHOD_BODY_STRICT").ok().as_deref() == Some("1") {
|
||||
if looks_like_method_head(self) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
statements.push(self.parse_statement()?);
|
||||
}
|
||||
if trace_blocks {
|
||||
|
||||
Reference in New Issue
Block a user