Add pattern statement
This commit is contained in:
1 parent
04367db0ac
commit
e7e30c4f28
5 files changed
+51
-8
No files matched your search
@@ -110,4 +110,17 @@ EOF
|
||||
compile("spec/test_user_code.d")
|
||||
run
|
||||
end
|
||||
|
||||
it "supports a pattern statement" do
|
||||
write_grammar <<EOF
|
||||
token abc;
|
||||
/def/ <<
|
||||
writeln("def!");
|
||||
>>
|
||||
Start -> abc;
|
||||
EOF
|
||||
build_parser
|
||||
compile("spec/test_pattern.d")
|
||||
run
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
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);
|
||||
|
||||
input = "defabcdef";
|
||||
parser = new Testparser.Parser(cast(const(ubyte) *)input.ptr, input.length);
|
||||
assert(parser.parse() == true);
|
||||
}
|
||||
Reference in new issue
Block a user