Skip to content

Instantly share code, notes, and snippets.

@TotallyNotAHaxxer
Created March 8, 2023 08:06
Show Gist options
  • Save TotallyNotAHaxxer/8f0ca06f4acedd93e5ea2b18ba746ae5 to your computer and use it in GitHub Desktop.
Save TotallyNotAHaxxer/8f0ca06f4acedd93e5ea2b18ba746ae5 to your computer and use it in GitHub Desktop.
Simple tree system for skyline
func (parser *Parser) ParserCreateAssignment() *LetStatement {
stmt := &LetStatement{Token: parser.CurrentToken}
if !parser.ExpectPeek(IDENT) {
return nil
}
stmt.Name = &Ident{Token: parser.CurrentToken, Value: parser.CurrentToken.Literal}
if !parser.ExpectPeek(ASSIGN) {
return nil
}
parser.NT()
stmt.Value = parser.parseExpression(LOWEST)
for !parser.CurrentTokenIs(SEMICOLON) {
if parser.CurrentTokenIs(EOF) {
var root *TreeNode
if FileCurrent.Filename == "" {
root = &TreeNode{
Type: SKYLINE_HIGH_DEFRED + "E | " + "REPL.skyline" + SKYLINE_RESTORE,
Children: []*TreeNode{
{
Type: SUNRISE_HIGH_DEFINITION + "Error Information Tree" + SKYLINE_RESTORE,
Children: []*TreeNode{
{
Type: SKYLINE_HIGH_DEFRED + "Code" + SKYLINE_RESTORE,
Children: []*TreeNode{
{
Type: SKYLINE_HIGH_DEFAQUA + "[I]: 0000_Unknown" + SKYLINE_RESTORE,
},
},
},
{
Type: SKYLINE_HIGH_DEFRED + "Type" + SKYLINE_RESTORE,
Children: []*TreeNode{
{
Type: SKYLINE_HIGH_DEFAQUA +
"[I] Parser Error (parse create assignment)" +
SKYLINE_RESTORE,
},
},
},
{
Type: SKYLINE_HIGH_DEFRED + "Message" + SKYLINE_RESTORE,
Children: []*TreeNode{
{
Type: SKYLINE_HIGH_DEFAQUA +
"[I]: Unterminated set/cause/let statement" + SKYLINE_RESTORE,
},
},
},
{
Type: SUNRISE_LIGHT_DEFINITION + "Suggestion" + SKYLINE_RESTORE,
Children: []*TreeNode{
{
Type: SKYLINE_HIGH_DEFAQUA + "[I]: Consider adding a semicolon to the end of the statement (';')" + SKYLINE_RESTORE,
},
},
},
},
},
},
}
} else {
root = &TreeNode{
Type: SKYLINE_HIGH_DEFRED + "E | " + FileCurrent.Get_Name() + SKYLINE_RESTORE,
Children: []*TreeNode{
{
Type: SUNRISE_HIGH_DEFINITION + "Error Information Tree" + SKYLINE_RESTORE,
Children: []*TreeNode{
{
Type: SKYLINE_HIGH_DEFRED + "Code" + SKYLINE_RESTORE,
Children: []*TreeNode{
{
Type: SKYLINE_HIGH_DEFAQUA + "[I]: 0000_Unknown" + SKYLINE_RESTORE,
},
},
},
{
Type: SKYLINE_HIGH_DEFRED + "Type" + SKYLINE_RESTORE,
Children: []*TreeNode{
{
Type: SKYLINE_HIGH_DEFAQUA +
"[I] Parser Error (parse create assignment)" +
SKYLINE_RESTORE,
},
},
},
{
Type: SKYLINE_HIGH_DEFRED + "Message" + SKYLINE_RESTORE,
Children: []*TreeNode{
{
Type: SKYLINE_HIGH_DEFAQUA +
"[I]: Unterminated set/cause/let statement" + SKYLINE_RESTORE,
},
},
},
{
Type: SUNRISE_LIGHT_DEFINITION + "Suggestion" + SKYLINE_RESTORE,
Children: []*TreeNode{
{
Type: SKYLINE_HIGH_DEFAQUA + "[I]: Consider adding a semicolon to the end of the statement (';')" + SKYLINE_RESTORE,
},
},
},
},
},
},
}
}
RetTreeSys(root, "", true)
parser.Errors = append(parser.Errors, "")
return nil
}
parser.NT()
}
return stmt
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment