Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented rewriter for :: operator. Added specs
- Loading branch information
Showing
5 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
Akin Parser Rewrite = Origin mimic | ||
use("akin/parser/rewrite/colon") | ||
use("akin/parser/rewrite/dcolon") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
Akin Parser Rewrite DColon = Origin mimic | ||
Akin Parser Rewrite DColon do( | ||
|
||
rewrite = method(chain, | ||
m = chain | ||
while(m, | ||
if(m next && m next next && m next dcolonArgOp?, | ||
m = m next next | ||
chain = process(m previous) first | ||
) | ||
if(m body && m body message, rewrite(m body message)) | ||
m = m next) | ||
chain | ||
) | ||
|
||
process = method(dcolon, | ||
first = dcolon firstInLine findForward(white? not) | ||
into = dcolon next findForward(white? not) | ||
upto = dcolon previous | ||
|
||
nl = first previous | ||
nl next = into | ||
into previous = nl | ||
|
||
first previous = nil | ||
upto next = nil | ||
|
||
into appendArgument(first) | ||
into | ||
) | ||
|
||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use("ispec") | ||
|
||
use("akin") | ||
use("akin/parser") | ||
|
||
describe("Akin Parser", | ||
|
||
parse = fn(txt, | ||
tokens = Akin Tokenizer parseText(txt) | ||
Akin Parser Rewrite DColon rewrite(tokens)) | ||
|
||
it("should append previous message as argument to next", | ||
msg = parse("foo :: baz") | ||
msg code should == "baz(foo )" | ||
) | ||
|
||
it("should append previous messages as argument to next", | ||
msg = parse("hello\n foo, bar :: baz") | ||
msg code should == "hello\n baz(foo, bar )" | ||
) | ||
|
||
it("should handle chained :: operators", | ||
msg = parse("foo, bar :: if(hello) :: if(bye)") | ||
msg code should == "if(bye,if(hello,foo, bar ) )" | ||
) | ||
|
||
|
||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
|
||
use(System currentDirectory +"/parser/rewrite/colon_spec.ik") | ||
use(System currentDirectory +"/parser/rewrite/dcolon_spec.ik") | ||
|
||
|
||
|