diff --git a/lib/collections.nom b/lib/collections.nom index ac1b019..a2ee0cc 100644 --- a/lib/collections.nom +++ b/lib/collections.nom @@ -75,6 +75,29 @@ immediately end)() parse [%expression for all %iterable] as: %expression for % in %iterable + compile [..] + %expression for %index from %start to %stop via %step + %expression for %index from %start to %stop by %step + ..to + assume ((%index's "type") is "Var") or barf ".." + List comprehension has the wrong type for the loop variable. Expected Var, but got: \(%index's "type") + return {..} + expr:".." + (function() + local comprehension = {}; + for \(%index as lua expr)=\(%start as lua expr),\(%stop as lua expr),\(%step as lua expr) do + comprehension[\(%index as lua expr)] = \(%expression as lua expr); + end + return comprehension; + end)() + parse [%expression for all ] as: %expression for % in %iterable + parse [%expression for %var from %start to %stop] as: %expression for %var from %start to %stop via 1 + parse [..] + %expression for all %start to %stop by %step + %expression for all %start to %stop via %step + ..as: %expression for % from %start to %stop via %step + parse [%expression for all %start to %stop] as: %expression for all %start to %stop via 1 + compile [%expression for %key = %value in %iterable] to assume ((%key's "type") is "Var") or barf ".." List comprehension has the wrong type for the key loop variable. Expected Var, but got: \(%key's "type") diff --git a/lib/class.nom b/lib/object.nom similarity index 100% rename from lib/class.nom rename to lib/object.nom