Remove std.stdio import and printing of unexpected tokens
This commit is contained in:
parent
d39fa61af0
commit
c4bcb465da
@ -3,12 +3,10 @@
|
|||||||
*
|
*
|
||||||
* This file is generated by Propane.
|
* This file is generated by Propane.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
<% if @grammar.modulename %>
|
<% if @grammar.modulename %>
|
||||||
module <%= @grammar.modulename %>;
|
|
||||||
|
|
||||||
|
module <%= @grammar.modulename %>;
|
||||||
<% end %>
|
<% end %>
|
||||||
import std.stdio;
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* User code blocks
|
* User code blocks
|
||||||
@ -913,16 +911,6 @@ public size_t <%= @grammar.prefix %>parse(<%= @grammar.prefix %>context_t * cont
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Error, unexpected token. */
|
|
||||||
write("Unexpected token ");
|
|
||||||
if (token != INVALID_TOKEN_ID)
|
|
||||||
{
|
|
||||||
writeln(<%= @grammar.prefix %>token_names[token]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
writeln("{other}");
|
|
||||||
}
|
|
||||||
/* A token was successfully lexed, so the input text position was
|
/* A token was successfully lexed, so the input text position was
|
||||||
* advanced. However, this is an unexpected token, so we want to reset
|
* advanced. However, this is an unexpected token, so we want to reset
|
||||||
* the context text position to point to the token rather than the text
|
* the context text position to point to the token rather than the text
|
||||||
|
@ -228,6 +228,9 @@ EOF
|
|||||||
|
|
||||||
it "executes user code when matching lexer token" do
|
it "executes user code when matching lexer token" do
|
||||||
write_grammar <<EOF
|
write_grammar <<EOF
|
||||||
|
<<
|
||||||
|
import std.stdio;
|
||||||
|
>>
|
||||||
token abc <<
|
token abc <<
|
||||||
writeln("abc!");
|
writeln("abc!");
|
||||||
>>
|
>>
|
||||||
@ -251,6 +254,9 @@ EOF
|
|||||||
|
|
||||||
it "supports a pattern statement" do
|
it "supports a pattern statement" do
|
||||||
write_grammar <<EOF
|
write_grammar <<EOF
|
||||||
|
<<
|
||||||
|
import std.stdio;
|
||||||
|
>>
|
||||||
token abc;
|
token abc;
|
||||||
/def/ <<
|
/def/ <<
|
||||||
writeln("def!");
|
writeln("def!");
|
||||||
@ -272,6 +278,9 @@ EOF
|
|||||||
|
|
||||||
it "supports returning tokens from pattern code blocks" do
|
it "supports returning tokens from pattern code blocks" do
|
||||||
write_grammar <<EOF
|
write_grammar <<EOF
|
||||||
|
<<
|
||||||
|
import std.stdio;
|
||||||
|
>>
|
||||||
token abc;
|
token abc;
|
||||||
/def/ <<
|
/def/ <<
|
||||||
writeln("def!");
|
writeln("def!");
|
||||||
@ -295,6 +304,9 @@ EOF
|
|||||||
|
|
||||||
it "supports lexer modes" do
|
it "supports lexer modes" do
|
||||||
write_grammar <<EOF
|
write_grammar <<EOF
|
||||||
|
<<
|
||||||
|
import std.stdio;
|
||||||
|
>>
|
||||||
token abc;
|
token abc;
|
||||||
token def;
|
token def;
|
||||||
tokenid string;
|
tokenid string;
|
||||||
@ -328,6 +340,9 @@ EOF
|
|||||||
|
|
||||||
it "executes user code associated with a parser rule" do
|
it "executes user code associated with a parser rule" do
|
||||||
write_grammar <<EOF
|
write_grammar <<EOF
|
||||||
|
<<
|
||||||
|
import std.stdio;
|
||||||
|
>>
|
||||||
token a;
|
token a;
|
||||||
token b;
|
token b;
|
||||||
Start -> A B <<
|
Start -> A B <<
|
||||||
@ -393,6 +408,9 @@ EOF
|
|||||||
|
|
||||||
it "provides matched text to user code blocks" do
|
it "provides matched text to user code blocks" do
|
||||||
write_grammar <<EOF
|
write_grammar <<EOF
|
||||||
|
<<
|
||||||
|
import std.stdio;
|
||||||
|
>>
|
||||||
token id /[a-zA-Z_][a-zA-Z0-9_]*/ <<
|
token id /[a-zA-Z_][a-zA-Z0-9_]*/ <<
|
||||||
writeln("Matched token is ", match);
|
writeln("Matched token is ", match);
|
||||||
>>
|
>>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user