summaryrefslogtreecommitdiff
path: root/example.lua
diff options
context:
space:
mode:
Diffstat (limited to 'example.lua')
-rw-r--r--example.lua21
1 files changed, 16 insertions, 5 deletions
diff --git a/example.lua b/example.lua
index 2bd87fa..9f4a852 100644
--- a/example.lua
+++ b/example.lua
@@ -17,10 +17,15 @@ for line in csvFile:lines() do
end
end
-print(#data)
-for i, v in ipairs(data[1]) do
- print(i, v)
-end
+
+local metaproduction = {}
+metaproduction["<start>"] = {{'<functions>'}}
+metaproduction["<functions>"] = { {}, {'<function>', '<functions>'} }
+metaproduction["<function>"] = {{ 'defun(', '<arity>', ')\n' }}
+metaproduction["<arity>"] = { {'0'}, {'1+', '<arity>'} }
+
+local metagrammar = Grammar.createGrammar(metaproduction, {})
+
local production = {}
production["<start>"]={{'<expr>'}}
@@ -41,7 +46,8 @@ production["<number>"]={ {'0.','<digit>','<digit>','<digit>'} }
local grammar = Grammar.createGrammar(production, {})
-math.randomseed(0)
+--math.randomseed(0)
+math.randomseed(os.time())
function randomGenome()
@@ -54,6 +60,11 @@ function randomGenome()
end
+local g = randomGenome()
+print(#g, metagrammar:expand(randomGenome()))
+os.exit(0)
+
+
function randomPop()
local pop = {}
for n=1,1000 do