From ea5ef2fe245c09b35c783977928d6e995110cfb4 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Mon, 30 Aug 2021 19:07:26 -0400 Subject: Scrap old spec, add initial value parsing --- src/tparse/tree-preproc.go | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/tparse/tree-preproc.go (limited to 'src/tparse/tree-preproc.go') diff --git a/src/tparse/tree-preproc.go b/src/tparse/tree-preproc.go new file mode 100644 index 0000000..d0f6637 --- /dev/null +++ b/src/tparse/tree-preproc.go @@ -0,0 +1,49 @@ +/* + Copyright 2020 Kyle Gunger + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package tparse + +func parsePreBlock (tokens *[]Token, tok, max int) (Node, int) { + out := Node{IsBlock: true} + out.Data = Token{Type: 11, Data: (*tokens)[tok].Data} + + tok++ + + for ; tok < max; tok++ { + t := (*tokens)[tok] + + if t.Data == ":/" { + break + } + + tmp := Node{Data: t, IsBlock: false} + out.Sub = append(out.Sub, tmp) + } + + return out, tok +} + +func parsePre (tokens *[]Token, tok, max int) (Node, int) { + out := Node{IsBlock: false} + out.Data = Token{Type: 11, Data: (*tokens)[tok].Data} + + tok++ + + tmp := Node{Data: (*tokens)[tok], IsBlock: false} + out.Sub = append(out.Sub, tmp) + + return out, tok +} \ No newline at end of file -- cgit v1.2.3