Refactor: Rename map to record
This commit renames `Map` to `Record` and updates all related AST nodes, binders, type checkers, and runtime values to reflect this change. This is a semantic change to better align with common programming language terminology.
This commit is contained in:
+8
-8
@@ -31,7 +31,7 @@ impl<'a> Parser<'a> {
|
||||
match self.peek() {
|
||||
TokenKind::LeftParen => self.parse_list(),
|
||||
TokenKind::LeftBracket => self.parse_vector_literal(),
|
||||
TokenKind::LeftBrace => self.parse_map_literal(),
|
||||
TokenKind::LeftBrace => self.parse_record_literal(),
|
||||
TokenKind::Quote => {
|
||||
self.advance()?; // consume '
|
||||
let expr = self.parse_expression()?;
|
||||
@@ -292,13 +292,13 @@ impl<'a> Parser<'a> {
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_map_literal(&mut self) -> Result<Node<UntypedKind>, String> {
|
||||
fn parse_record_literal(&mut self) -> Result<Node<UntypedKind>, String> {
|
||||
let token = self.advance()?;
|
||||
let mut entries = Vec::new();
|
||||
let mut fields = Vec::new();
|
||||
|
||||
while *self.peek() != TokenKind::RightBrace {
|
||||
if *self.peek() == TokenKind::EOF {
|
||||
return Err("Unexpected EOF in map literal".to_string());
|
||||
return Err("Unexpected EOF in record literal".to_string());
|
||||
}
|
||||
|
||||
let key_node = self.parse_expression()?;
|
||||
@@ -307,21 +307,21 @@ impl<'a> Parser<'a> {
|
||||
// Delphi enforces keywords. We can do minimal check here.
|
||||
match &key_node.kind {
|
||||
UntypedKind::Constant(Value::Keyword(_)) => {},
|
||||
_ => return Err("Map keys must be keywords (syntactically)".to_string()),
|
||||
_ => return Err("Record keys must be keywords (syntactically)".to_string()),
|
||||
}
|
||||
|
||||
if *self.peek() == TokenKind::RightBrace {
|
||||
return Err("Map literal must have even number of forms".to_string());
|
||||
return Err("Record literal must have even number of forms".to_string());
|
||||
}
|
||||
let val_node = self.parse_expression()?;
|
||||
|
||||
entries.push((key_node, val_node));
|
||||
fields.push((key_node, val_node));
|
||||
}
|
||||
self.expect(TokenKind::RightBrace)?;
|
||||
|
||||
Ok(Node {
|
||||
identity: Rc::new(NodeIdentity { location: token.location }),
|
||||
kind: UntypedKind::Map { entries },
|
||||
kind: UntypedKind::Record { fields },
|
||||
ty: (),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user