Add pattern statement

This commit is contained in:
josh committed 2022-09-30 21:05:18 -04:00
1 parent 04367db0ac
commit e7e30c4f28
5 files changed
+51 -8

No files matched your search

+13
View File
@@ -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
+18
View File
@@ -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);
}