From 0a067524ce42354315205cfaa0031df9898b8164 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sun, 14 Aug 2022 22:38:57 -0400 Subject: [PATCH] Added base parse body function --- parser/body.go | 18 ++++++++++++++++++ parser/data.go | 6 ++++++ parser/meta.go | 3 +++ parser/parser.go | 3 +++ tests/parser/data/main.arf | 27 +++++++++++++++++++++++++++ 5 files changed, 57 insertions(+) create mode 100644 parser/body.go create mode 100644 parser/data.go create mode 100644 tests/parser/data/main.arf diff --git a/parser/body.go b/parser/body.go new file mode 100644 index 0000000..cd05305 --- /dev/null +++ b/parser/body.go @@ -0,0 +1,18 @@ +package parser + +import "git.tebibyte.media/sashakoshka/arf/lexer" + +// parse body parses the body of an arf file, after the metadata header. +func (parser *ParsingOperation) parseBody () (err error) { + err = parser.nextToken(lexer.TokenKindName) + if err != nil { return } + + switch parser.token.Value().(string) { + case "data": + case "type": + case "func": + case "face": + } + + return +} diff --git a/parser/data.go b/parser/data.go new file mode 100644 index 0000000..9f72e54 --- /dev/null +++ b/parser/data.go @@ -0,0 +1,6 @@ +package parser + +// parseData parses a data section +func (parser *ParsingOperation) parseData () (err error) { + +} diff --git a/parser/meta.go b/parser/meta.go index 1ea5970..94fa46f 100644 --- a/parser/meta.go +++ b/parser/meta.go @@ -12,6 +12,9 @@ func (parser *ParsingOperation) parseMeta () (err error) { if err != nil { return } if parser.token.Is(lexer.TokenKindSeparator) { + err = parser.nextToken(lexer.TokenKindNewline) + if err != nil { return } + err = parser.nextToken() return } diff --git a/parser/parser.go b/parser/parser.go index 90d2603..3907a53 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -64,6 +64,9 @@ func (parser *ParsingOperation) parse (sourceFile *file.File) (err error) { err = parser.parseMeta() if err != nil { return } + err = parser.parseBody() + if err != nil { return } + return } diff --git a/tests/parser/data/main.arf b/tests/parser/data/main.arf new file mode 100644 index 0000000..d3419cd --- /dev/null +++ b/tests/parser/data/main.arf @@ -0,0 +1,27 @@ +:arf +--- + +data wr integer:Int 3202 + +data wr integerPointer:{Int} +# TODO: data wr integerPointer:{Int} [& integer] + +data wr integerArray16:{Int 16} + +data wr integerArrayVariable:{Int ...} + +data wr integerArrayInitialized:{Int 16} + 3948 293 293049 948 912 + 340 0 2304 0 4785 92 + +data wr object:Obj + : this 324 + : that 2139 + +data wr nestedObject:Obj + : this + : bird0 324 + : bird1 "hello world" + : that + : bird2 123.8439 + : bird3 9328.21348239