Execute user code blocks assigned to tokens
This commit is contained in:
1 parent
92ce30f354
commit
672098ad32
6 files changed
+122
-8
No files matched your search
@@ -95,4 +95,19 @@ EOF
|
||||
compile("spec/test_d_lexer2.d")
|
||||
run
|
||||
end
|
||||
|
||||
it "executes user code when matching lexer token" do
|
||||
write_grammar <<EOF
|
||||
token abc <<
|
||||
writeln("abc!");
|
||||
>>
|
||||
token def;
|
||||
Start -> Abcs def;
|
||||
Abcs -> ;
|
||||
Abcs -> abc Abcs;
|
||||
EOF
|
||||
build_parser
|
||||
compile("spec/test_user_code.d")
|
||||
run
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,20 @@
|
||||
import testparser;
|
||||
import std.stdio;
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
string input = "abcdef";
|
||||
auto parser = new Testparser.Parser(cast(const(ubyte) *)input.ptr, input.length);
|
||||
assert(parser.parse() == true);
|
||||
writeln("pass1");
|
||||
|
||||
input = "abcabcdef";
|
||||
parser = new Testparser.Parser(cast(const(ubyte) *)input.ptr, input.length);
|
||||
assert(parser.parse() == true);
|
||||
writeln("pass2");
|
||||
}
|
||||
Reference in new issue
Block a user