all: add quasiquoting
This commit is contained in:
@@ -145,6 +145,36 @@ func parseToken(input []string) (*ast.AST, error, []string) {
|
||||
return &res, nil, input
|
||||
}
|
||||
|
||||
if input[0] == "`" {
|
||||
input = input[1:]
|
||||
tmp, err, input := parseToken(input)
|
||||
|
||||
if err != nil {
|
||||
return nil, err, input
|
||||
}
|
||||
|
||||
quote := ast.AST{ast.Symbol, "quasiquote"}
|
||||
res := ast.AST{ast.List, []*ast.AST{"e, tmp}}
|
||||
return &res, nil, input
|
||||
}
|
||||
|
||||
if input[0][0] == '@' {
|
||||
if input[0] == "@" {
|
||||
input = input[1:]
|
||||
} else {
|
||||
input = append([]string{input[0][1:]}, input[1:]...)
|
||||
}
|
||||
tmp, err, input := parseToken(input)
|
||||
|
||||
if err != nil {
|
||||
return nil, err, input
|
||||
}
|
||||
|
||||
unquote := ast.AST{ast.Symbol, "unqote"}
|
||||
res := ast.AST{ast.List, []*ast.AST{&unquote, tmp}}
|
||||
return &res, nil, input
|
||||
}
|
||||
|
||||
switch input[0] {
|
||||
case "(":
|
||||
{
|
||||
|
Reference in New Issue
Block a user