From 6d2eab4e44dd6eb600d86b79c52b5cfeeb0399ee Mon Sep 17 00:00:00 2001 From: Booklordofthedings Date: Mon, 5 Aug 2024 00:46:48 +0200 Subject: [PATCH] Basic implementation of parser --- BeefSpace.toml | 3 +++ src/BofaParser.bf | 43 +++++++++++++++++++++++++++++++++++++++ src/Parser/ParserEntry.bf | 3 ++- src/Testing/Default.bf | 9 ++++++++ 4 files changed, 57 insertions(+), 1 deletion(-) diff --git a/BeefSpace.toml b/BeefSpace.toml index 0bb5a2b..ba54fc1 100644 --- a/BeefSpace.toml +++ b/BeefSpace.toml @@ -3,3 +3,6 @@ Projects = {Bofa = {Path = "."}} [Workspace] StartupProject = "Bofa" + +[Configs.Test.Win64] +LargeStrings = true diff --git a/src/BofaParser.bf b/src/BofaParser.bf index 607f183..909572c 100644 --- a/src/BofaParser.bf +++ b/src/BofaParser.bf @@ -1,5 +1,48 @@ namespace Bofa; +using System; +using System.IO; +using System.Collections; + +using Bofa.Parser; + class BofaParser { + + public static Result Parse(StringView pToParse, List pResult) + { + StringStream stream = new .(pToParse, .Reference); + defer delete stream; + return Parse(stream, pResult); + } + + public static Result Parse(Stream pToParse, List pResult) + { + if(pToParse == null || pResult == null) + return .Err(-1); + + StreamReader reader = new .(pToParse); + defer delete reader; + + int64 line = 1; + while(reader.Peek() case .Ok) //This might technically cause an issue when there is data added to the stream while we where busy processing, but if you hook this up to a network stream you deserve this happening to you + { + String l = scope .(); + if(reader.ReadLine(l) case .Err) + return .Err(-2); + var entry = ParseLine(l, line); + line++; + } + + return .Ok; + } + + private static ParserEntry ParseLine(StringView pLine, int64 pLineNumber) + { + StringView line = pLine; + ParserEntry toReturn = .(); + + uint32 depth; + return .(); + } } \ No newline at end of file diff --git a/src/Parser/ParserEntry.bf b/src/Parser/ParserEntry.bf index d720a68..d1b1ecf 100644 --- a/src/Parser/ParserEntry.bf +++ b/src/Parser/ParserEntry.bf @@ -4,7 +4,8 @@ using System; struct ParserEntry { - public uint64 Line; + public int64 Line; + public int64 Depth = 0; public EParserEntryType Type; public ParserEntryUnion Data; } \ No newline at end of file diff --git a/src/Testing/Default.bf b/src/Testing/Default.bf index b09dd4f..b8e89bf 100644 --- a/src/Testing/Default.bf +++ b/src/Testing/Default.bf @@ -1,5 +1,14 @@ namespace Bofa.Testing; +using System; +using System.IO; + class Default { + [Test] + public static void Default_Test_1() + { + BofaParser.Parse("Without an ending", scope .()).IgnoreError(); + + } } \ No newline at end of file