nightshade

The nightshade programming language, compiler and tools (WIP)
Log | Files | Refs

commit cb15c520e420cfcdfb5a77b58a2b5e1462e998e2
parent 10a3de5beed24850ffda5a0610af89b87a9d7e8d
Author: citbl <citbl@citbl.org>
Date:   Thu,  4 Jun 2026 22:38:23 +1000

parsing wip

Diffstat:
Msrc/parser.adb | 29++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/src/parser.adb b/src/parser.adb @@ -14,14 +14,37 @@ package body Parser is -- peek function Peek (P : in Parser) return Token is - T : Token; begin if P.Pos < P.Tokens.Last_Index then - T := P.Tokens (P.Pos + 1); + return P.Tokens (P.Pos); + else + return Token'(Kind => EOF, Lexeme => To_Unbounded_String (""), Line => 1, Col => 1); + end if; + end Peek; + + -- peek2 + + function Peek2 (P : in Parser) return Token is + begin + if P.Pos + 1 < P.Tokens.Last_Index then + return P.Tokens (P.Pos + 1); + else + return Token'(Kind => EOF, Lexeme => To_Unbounded_String (""), Line => 1, Col => 1); end if; - return Token'(Kind => EOF, Lexeme => To_Unbounded_String(""), Line => 1, Col => 1); end Peek; + function Consume (P : in out Parser) return Token is + T : Token; + begin + if P.Pos < P.Tokens.Last_Index then + T := P.Tokens (P.Pos); + P.Pos := P.Pos + 1; + return T; + else + return Token'(Kind => EOF, Lexeme => To_Unbounded_String (""), Line => 1, Col => 1); + end if; + end Consume; + -- parse program function Parse_Program (P : in out Parser) return Node_Ref is