Add basic compiler, parser, and main program + GNU LGPL
This commit is contained in:
parent
863498439a
commit
0a0b3745d0
4 changed files with 154 additions and 0 deletions
30
parser/parser.go
Normal file
30
parser/parser.go
Normal file
|
@ -0,0 +1,30 @@
|
|||
package parser
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// THE HYLIA PARSER
|
||||
|
||||
func ParseFile(filename string) ([]string error) {
|
||||
// Hey, does the file we're trying to parse actually exist?
|
||||
data, err := ioutil.ReadFile(filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Parse the file, and ask "Is this a Hylia file?"
|
||||
content := string(data)
|
||||
if !strings.Contains(content, "<hylia>")|| !strings.Contains(content, "</hylia>") {
|
||||
return nil, errors.New("The structure of this file is invalid. Are you sure this is a Hylia (.hy) file?")
|
||||
}
|
||||
|
||||
// Extract the custom elements, which are wrapped in <element> tags
|
||||
elements := []string{}
|
||||
// ... TODO
|
||||
|
||||
return elements, nil
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue