Skip to content

Commit

Permalink
groovy: Fix exception on literal empty list
Browse files Browse the repository at this point in the history
  • Loading branch information
dubek committed Apr 1, 2016
1 parent 4525f9e commit 8ec0c2e
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions groovy/step3_env.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ eval_ast = { ast, env ->
EVAL = { ast, env ->
//println("EVAL: ${printer.pr_str(ast,true)}")
if (! types.list_Q(ast)) return eval_ast(ast, env)
if (ast.size() == 0) return ast

switch (ast[0]) {
case { it instanceof MalSymbol && it.value == "def!" }:
Expand Down
1 change: 1 addition & 0 deletions groovy/step4_if_fn_do.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ eval_ast = { ast, env ->
EVAL = { ast, env ->
//println("EVAL: ${printer.pr_str(ast,true)}")
if (! types.list_Q(ast)) return eval_ast(ast, env)
if (ast.size() == 0) return ast

switch (ast[0]) {
case { it instanceof MalSymbol && it.value == "def!" }:
Expand Down
1 change: 1 addition & 0 deletions groovy/step5_tco.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ EVAL = { ast, env ->
while (true) {
//println("EVAL: ${printer.pr_str(ast,true)}")
if (! types.list_Q(ast)) return eval_ast(ast, env)
if (ast.size() == 0) return ast

switch (ast[0]) {
case { it instanceof MalSymbol && it.value == "def!" }:
Expand Down
1 change: 1 addition & 0 deletions groovy/step6_file.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ EVAL = { ast, env ->
while (true) {
//println("EVAL: ${printer.pr_str(ast,true)}")
if (! types.list_Q(ast)) return eval_ast(ast, env)
if (ast.size() == 0) return ast

switch (ast[0]) {
case { it instanceof MalSymbol && it.value == "def!" }:
Expand Down
1 change: 1 addition & 0 deletions groovy/step7_quote.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ EVAL = { ast, env ->
while (true) {
//println("EVAL: ${printer.pr_str(ast,true)}")
if (! types.list_Q(ast)) return eval_ast(ast, env)
if (ast.size() == 0) return ast

switch (ast[0]) {
case { it instanceof MalSymbol && it.value == "def!" }:
Expand Down
2 changes: 2 additions & 0 deletions groovy/step8_macros.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ READ = { str ->
// EVAL
macro_Q = { ast, env ->
if (types.list_Q(ast) &&
ast.size() > 0 &&
ast[0].class == MalSymbol &&
env.find(ast[0])) {
def obj = env.get(ast[0])
Expand Down Expand Up @@ -70,6 +71,7 @@ EVAL = { ast, env ->

ast = macroexpand(ast, env)
if (! types.list_Q(ast)) return eval_ast(ast, env)
if (ast.size() == 0) return ast

switch (ast[0]) {
case { it instanceof MalSymbol && it.value == "def!" }:
Expand Down
2 changes: 2 additions & 0 deletions groovy/step9_try.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ READ = { str ->
// EVAL
macro_Q = { ast, env ->
if (types.list_Q(ast) &&
ast.size() > 0 &&
ast[0].class == MalSymbol &&
env.find(ast[0])) {
def obj = env.get(ast[0])
Expand Down Expand Up @@ -70,6 +71,7 @@ EVAL = { ast, env ->

ast = macroexpand(ast, env)
if (! types.list_Q(ast)) return eval_ast(ast, env)
if (ast.size() == 0) return ast

switch (ast[0]) {
case { it instanceof MalSymbol && it.value == "def!" }:
Expand Down
2 changes: 2 additions & 0 deletions groovy/stepA_mal.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ READ = { str ->
// EVAL
macro_Q = { ast, env ->
if (types.list_Q(ast) &&
ast.size() > 0 &&
ast[0].class == MalSymbol &&
env.find(ast[0])) {
def obj = env.get(ast[0])
Expand Down Expand Up @@ -70,6 +71,7 @@ EVAL = { ast, env ->

ast = macroexpand(ast, env)
if (! types.list_Q(ast)) return eval_ast(ast, env)
if (ast.size() == 0) return ast

switch (ast[0]) {
case { it instanceof MalSymbol && it.value == "def!" }:
Expand Down

0 comments on commit 8ec0c2e

Please sign in to comment.