From f7b9ea9ccfd8be8c2633b4d02dbc3207c2e3d354 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Tue, 10 Mar 2026 17:28:27 +0100 Subject: Remove the module declaration --- grammar | 3 +-- oryxc/src/lexer.rs | 1 - oryxc/src/parser.rs | 41 ----------------------------------------- test.yx | 2 -- 4 files changed, 1 insertion(+), 46 deletions(-) diff --git a/grammar b/grammar index 0bb9406..5fa2e73 100644 --- a/grammar +++ b/grammar @@ -1,6 +1,5 @@ -root: module-decl top-level*; +root: top-level*; -module-decl: "module" ident ";"; top-level: def-bind ";"; def-bind: "def" decl-list "=" expr-list; diff --git a/oryxc/src/lexer.rs b/oryxc/src/lexer.rs index 2f82e47..ace0a83 100644 --- a/oryxc/src/lexer.rs +++ b/oryxc/src/lexer.rs @@ -124,7 +124,6 @@ impl<'a> LexerContext<'a> { static KEYWORDS: phf::Map<&'static str, TokenType> = phf::phf_map! { "def" => TokenType::KeywordDef, "func" => TokenType::KeywordFunc, - "module" => TokenType::KeywordModule, "return" => TokenType::KeywordReturn, }; diff --git a/oryxc/src/parser.rs b/oryxc/src/parser.rs index 52c2a34..89e2769 100644 --- a/oryxc/src/parser.rs +++ b/oryxc/src/parser.rs @@ -34,7 +34,6 @@ pub enum AstType { Root, /* (extra-data, extra-data-len) */ String, /* (_, _) */ UnaryOperator, /* (rhs, _) */ - ModuleDecl, /* (ident, _) */ } #[derive(Soars)] @@ -164,7 +163,6 @@ impl<'a> Parser<'a> { AstType::FunProto => node, AstType::Function => node, AstType::Identifier => node, - AstType::ModuleDecl => node, AstType::MultiDefBind => node, AstType::Number => node, AstType::Pointer => node, @@ -229,9 +227,6 @@ impl<'a> Parser<'a> { self.node_leaf_r(self.ast.sub()[node as usize].1) }, AstType::Identifier => node, - AstType::ModuleDecl => { - self.node_leaf_r(self.ast.sub()[node as usize].0) - }, AstType::MultiDefBind => { let i = self.ast.sub()[node as usize].1; let len = self.extra_data[i as usize]; @@ -886,48 +881,12 @@ impl<'a> Parser<'a> { return Ok(lhs); } - - fn parse_module_decl(&mut self) -> bool { - let tok = self.cursor; /* Always 0 */ - if self.get() != TokenType::KeywordModule { - self.new_error(OryxError::new( - self.get_view(), - "file must begin with a module declaration", - )); - return false; - } - if self.next() != TokenType::Identifier { - self.new_error(OryxError::new( - self.get_view(), - format!("expected module name but got {:?}", self.get()), - )); - return true; - } - let ident = self.cursor; - if self.next() != TokenType::Semicolon { - self.new_error(OryxError::new( - self.get_view(), - "expected semicolon", - )); - return true; - } - self.next(); /* Consume ‘;’ */ - self.new_node(AstNode { - kind: AstType::ModuleDecl, - tok, - sub: SubNodes(ident, u32::MAX), - }); - return false; - } } pub fn parse( tokens: &Soa, ) -> Result<(Soa, Vec), Vec> { let mut p = Parser::new(tokens); - if p.parse_module_decl() { - p.sync(&[TokenType::Eof, TokenType::KeywordDef]); - } while p.get() != TokenType::Eof { p.parse_toplevel(); } diff --git a/test.yx b/test.yx index 2e3a515..b057812 100644 --- a/test.yx +++ b/test.yx @@ -1,5 +1,3 @@ -module foo; - def puts = $foreign("puts", func(s ^u8)); /* -- cgit v1.2.3