diff options
Diffstat (limited to 'src/tparse/tree-preproc.go')
-rw-r--r-- | src/tparse/tree-preproc.go | 49 |
1 files changed, 49 insertions, 0 deletions
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 |