Fix the reader bug in readUnquotedExpr function
This commit is contained in:
parent
1bd3a41fb6
commit
70bb8d1997
|
@ -44,7 +44,7 @@ for details take a look at the LICENSE file.
|
|||
`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
reader.ReadString("sameer mary")
|
||||
ast, _ := parser.ParseToAST("(asd mary)")
|
||||
ast, _ := parser.ParseToAST("(asd 'mary '(1 2 3) `(asd ~asd ~@zxc))")
|
||||
fmt.Printf("%s\n", ast.String())
|
||||
},
|
||||
}
|
||||
|
|
|
@ -211,17 +211,23 @@ func readUnquotedExpr(parser IParsable) (types.IExpr, error) {
|
|||
}
|
||||
|
||||
var sym types.IExpr
|
||||
expr, err := readExpr(parser)
|
||||
var err error
|
||||
var expr types.IExpr
|
||||
|
||||
if *c == "@" {
|
||||
parser.next(true)
|
||||
sym = types.MakeSymbol("unquote-splicing")
|
||||
expr, err = readExpr(parser)
|
||||
|
||||
} else {
|
||||
sym = types.MakeSymbol("unquote")
|
||||
expr, err = readExpr(parser)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if *c == "@" {
|
||||
sym = types.MakeSymbol("unquote-splicing")
|
||||
|
||||
} else {
|
||||
sym = types.MakeSymbol("unquote")
|
||||
}
|
||||
return types.MakeList([]types.IExpr{sym, expr}), nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue