diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2015-11-17 17:02:03 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2015-11-17 17:02:03 +0000 |
commit | 5e6124ea7eb07797e2df2d8ea5aa07e951ed4168 (patch) | |
tree | 2257b67ffb2f479fcab355df51df0ebaec562547 | |
parent | e35d5fe83fbce97f7ff110e62cb503406f4a32f8 (diff) | |
download | lace-5e6124ea7eb07797e2df2d8ea5aa07e951ed4168.tar.gz |
Convert subdefines from {} to []
Gitano uses ${user} to let you define rules about the current user.
Rather than significantly complicate the parser,
it's easier to change the token.
-rw-r--r-- | lib/lace/lex.lua | 4 | ||||
-rw-r--r-- | test/test-lace.compile-subdefine1.rules | 2 | ||||
-rw-r--r-- | test/test-lace.compile-subdefine2.rules | 2 | ||||
-rw-r--r-- | test/test-lace.engine-subdefine-error.rules | 4 | ||||
-rw-r--r-- | test/test-lace.engine-subdefine-works.rules | 2 | ||||
-rw-r--r-- | test/test-lace.engine-subsubdefine-error.rules | 2 | ||||
-rw-r--r-- | test/test-lace.engine-subsubdefine-works.rules | 2 | ||||
-rw-r--r-- | test/test-lace.engine.lua | 4 | ||||
-rw-r--r-- | test/test-lace.lex.lua | 2 |
9 files changed, 12 insertions, 12 deletions
diff --git a/lib/lace/lex.lua b/lib/lace/lex.lua index 2e99702..d7d18da 100644 --- a/lib/lace/lex.lua +++ b/lib/lace/lex.lua @@ -55,10 +55,10 @@ local function _lex_one_line(line, terminator) -- Start double quotes quoting = c force_empty = true - elseif c == '{' and quoting == false then + elseif c == '[' and quoting == false then if acc == "" then -- Something worth lexing - local ltab, rest, warns = lex_one_line(line, "}") + local ltab, rest, warns = lex_one_line(line, "]") -- For now, assume the accumulator is good enough cpos = cpos + #line - #rest r[#r+1] = { spos = spos, epos = cpos, sub = ltab } diff --git a/test/test-lace.compile-subdefine1.rules b/test/test-lace.compile-subdefine1.rules index c917225..a178960 100644 --- a/test/test-lace.compile-subdefine1.rules +++ b/test/test-lace.compile-subdefine1.rules @@ -1 +1 @@ -allow "Hurrah" {equal jeff} +allow "Hurrah" [equal jeff] diff --git a/test/test-lace.compile-subdefine2.rules b/test/test-lace.compile-subdefine2.rules index a753015..73bb608 100644 --- a/test/test-lace.compile-subdefine2.rules +++ b/test/test-lace.compile-subdefine2.rules @@ -1 +1 @@ -allow "OK" {anyof {equal user daniel} {equal user geoff}} +allow "OK" [anyof [equal user daniel] [equal user geoff]] diff --git a/test/test-lace.engine-subdefine-error.rules b/test/test-lace.engine-subdefine-error.rules index 9b0856d..19ca933 100644 --- a/test/test-lace.engine-subdefine-error.rules +++ b/test/test-lace.engine-subdefine-error.rules @@ -1,2 +1,2 @@ -deny "Boo" {equal jeff geoff} -allow "Yay" {error} +deny "Boo" [equal jeff geoff] +allow "Yay" [error] diff --git a/test/test-lace.engine-subdefine-works.rules b/test/test-lace.engine-subdefine-works.rules index 5454b07..d23fbc7 100644 --- a/test/test-lace.engine-subdefine-works.rules +++ b/test/test-lace.engine-subdefine-works.rules @@ -1,2 +1,2 @@ default deny -allow "PASS" {equal jeff geoff} +allow "PASS" [equal jeff geoff] diff --git a/test/test-lace.engine-subsubdefine-error.rules b/test/test-lace.engine-subsubdefine-error.rules index 78022af..10e2105 100644 --- a/test/test-lace.engine-subsubdefine-error.rules +++ b/test/test-lace.engine-subsubdefine-error.rules @@ -1 +1 @@ -allow "FAIL" {anyof {equal jeff banana} {error}} +allow "FAIL" [anyof [equal jeff banana] [error]] diff --git a/test/test-lace.engine-subsubdefine-works.rules b/test/test-lace.engine-subsubdefine-works.rules index 1fd3ee8..66bac21 100644 --- a/test/test-lace.engine-subsubdefine-works.rules +++ b/test/test-lace.engine-subsubdefine-works.rules @@ -1 +1 @@ -allow "PASS" {anyof {equal jeff harry} {equal jeff geoff}} +allow "PASS" [anyof [equal jeff harry] [equal jeff geoff]] diff --git a/test/test-lace.engine.lua b/test/test-lace.engine.lua index e8721fc..c5f7751 100644 --- a/test/test-lace.engine.lua +++ b/test/test-lace.engine.lua @@ -262,7 +262,7 @@ function suite.subdefine_err_reported() local line1, line2, line3, line4 = msg:match("^([^\n]*)\n([^\n]*)\n([^\n]*)\n([^\n]*)$") assert(line1 == "woah", "The first line must mention the error") assert(line2 == "real-subdefine-error :: 2", "The second line is where the error happened") - assert(line3 == 'allow "Yay" {error}', "The third line is the original line") + assert(line3 == 'allow "Yay" [error]', "The third line is the original line") assert(line4 == " ^^^^^^^", "The fourth line highlights relevant words") end @@ -285,7 +285,7 @@ function suite.subsubdefine_err_reported() local line1, line2, line3, line4 = msg:match("^([^\n]*)\n([^\n]*)\n([^\n]*)\n([^\n]*)$") assert(line1 == "woah", "The first line must mention the error") assert(line2 == "real-subsubdefine-error :: 1", "The second line is where the error happened") - assert(line3 == 'allow "FAIL" {anyof {equal jeff banana} {error}}', "The third line is the original line") + assert(line3 == 'allow "FAIL" [anyof [equal jeff banana] [error]]', "The third line is the original line") assert(line4 == " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", "The fourth line highlights relevant words") end diff --git a/test/test-lace.lex.lua b/test/test-lace.lex.lua index 36025b7..9fc50e1 100644 --- a/test/test-lace.lex.lua +++ b/test/test-lace.lex.lua @@ -269,7 +269,7 @@ function suite.empty_string_words_work() end function suite.braced_sections_sublex() - local content = assert(lex.string("foo {bar baz} meta", "SRC")) + local content = assert(lex.string("foo [bar baz] meta", "SRC")) assert(content.source == "SRC", "Source name not propagated") assert(type(content.lines) == "table", "Lines is not a table") assert(#content.lines == 1, "There should have been one line") |