Skip to content

Commit

Permalink
Merge pull request #184 from BBasile/backticked-lit
Browse files Browse the repository at this point in the history
More consistent error messages, always use backticks for literals
  • Loading branch information
wilzbach authored Dec 21, 2017
2 parents a69006e + 240dcf0 commit 1b0df8c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
6 changes: 3 additions & 3 deletions src/dparse/lexer.d
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,7 @@ private pure nothrow @safe:
}
else
{
error("Error: \" expected to end delimited string literal");
error("Error: `\"` expected to end delimited string literal");
token = Token(tok!"");
return;
}
Expand Down Expand Up @@ -1365,7 +1365,7 @@ private pure nothrow @safe:
range.popFront();
}
else
error(`" expected`);
error("`\"` expected");
IdType type = tok!"stringLiteral";
lexStringSuffix(type);
token = Token(type, cache.intern(range.slice(mark)), line, column, index);
Expand Down Expand Up @@ -1616,7 +1616,7 @@ private pure nothrow @safe:
else
{
err:
error("Error: Expected ' to end character literal");
error("Error: Expected `'` to end character literal");
token = Token(tok!"");
}
}
Expand Down
54 changes: 27 additions & 27 deletions src/dparse/parser.d
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ class Parser
node.identifierOrIntegerOrOpcode = advance();
if (!currentIs(tok!";"))
{
error("';' expected.");
error("`;` expected.");
advance();
return null;
}
Expand Down Expand Up @@ -660,7 +660,7 @@ class Parser
mixin(parseNodeQ!(`node.identifierChain`, `IdentifierChain`));
break;
default:
error("Float literal, integer literal, $, or identifier expected.");
error("Float literal, integer literal, `$`, or identifier expected.");
return null;
}
return node;
Expand Down Expand Up @@ -713,7 +713,7 @@ class Parser
{
if (!functionAttributes.put(parseFunctionAttribute()))
{
error("Function attribute or '{' expected");
error("Function attribute or `{` expected");
return null;
}
}
Expand Down Expand Up @@ -780,7 +780,7 @@ class Parser
node.right = advance();
return node;
default:
error("Expected an identifier, 'byte', 'short', 'int', 'float', 'double', or 'real'");
error("Expected an identifier, `byte`, `short`, `int`, `float`, `double`, or `real`");
return null;
}
}
Expand Down Expand Up @@ -977,7 +977,7 @@ class Parser
mixin (nullCheck!`start`);
if (!moreTokens)
{
error(`"(", or identifier expected`);
error("`(`, or identifier expected");
return null;
}
node.startLocation = start.index;
Expand All @@ -1002,7 +1002,7 @@ class Parser
expect(tok!")");
break;
default:
error(`"(", or identifier expected`);
error("`(`, or identifier expected");
return null;
}
if (moreTokens) node.endLocation = current().index;
Expand Down Expand Up @@ -1243,7 +1243,7 @@ class Parser
advance();
break;
default:
error("Identifier or semicolon expected following \"break\"");
error("Identifier or semicolon expected following `break`");
return null;
}
return node;
Expand Down Expand Up @@ -1424,7 +1424,7 @@ class Parser
node.first = advance();
break;
default:
error("const, immutable, inout, or shared expected");
error("`const`, `immutable`, `inout`, or `shared` expected");
return null;
}
return node;
Expand Down Expand Up @@ -1588,7 +1588,7 @@ class Parser
mixin(parseNodeQ!(`node.staticIfCondition`, `StaticIfCondition`));
break;
default:
error(`"version", "debug", or "static" expected`);
error("`version`, `debug`, or `static` expected");
return null;
}
return node;
Expand Down Expand Up @@ -1776,7 +1776,7 @@ class Parser
advance();
break;
default:
error(`Identifier or semicolon expected following "continue"`);
error("Identifier or semicolon expected following `continue`");
return null;
}
return node;
Expand Down Expand Up @@ -1966,7 +1966,7 @@ class Parser
case tok!"{":
if (node.attributes.empty)
{
error("declaration expected instead of '{'");
error("declaration expected instead of `{`");
return null;
}
advance();
Expand Down Expand Up @@ -2161,7 +2161,7 @@ class Parser
mixin(parseNodeQ!(`node.versionSpecification`, `VersionSpecification`));
else
{
error(`"=" or "(" expected following "version"`);
error("`=` or `(` expected following `version`");
return null;
}
break;
Expand Down Expand Up @@ -2367,7 +2367,7 @@ class Parser
mixin(tokenCheck!"~");
if (!moreTokens)
{
error("'this' expected");
error("`this` expected");
return null;
}
node.index = current.index;
Expand Down Expand Up @@ -2453,7 +2453,7 @@ class Parser
}
else
{
error("',' or '}' expected");
error("`,` or `}` expected");
if (currentIs(tok!"}"))
break;
}
Expand Down Expand Up @@ -2816,7 +2816,7 @@ class Parser
node.type = advance().type;
else
{
error(`"foreach" or "foreach_reverse" expected`);
error("`foreach` or `foreach_reverse` expected");
return null;
}
node.startIndex = current().index;
Expand Down Expand Up @@ -2965,7 +2965,7 @@ class Parser
break;
default:
if (validate)
error(`@attribute, "pure", or "nothrow" expected`);
error("`@`attribute, `pure`, or `nothrow` expected");
return null;
}
return node;
Expand Down Expand Up @@ -3011,7 +3011,7 @@ class Parser
}
else
{
error("'in', 'out', 'body', or block statement expected");
error("`in`, `out`, `body`, or block statement expected");
return null;
}
return node;
Expand Down Expand Up @@ -3105,7 +3105,7 @@ class Parser
mixin(tokenCheck!(`node.name`, "identifier"));
if (!currentIs(tok!"("))
{
error("'(' expected");
error("`(` expected");
return null;
}
const p = peekPastParens();
Expand Down Expand Up @@ -3216,7 +3216,7 @@ class Parser
mixin(parseNodeQ!(`node.expression`, `Expression`));
break;
default:
error(`Identifier, "default", or "case" expected`);
error("Identifier, `default`, or `case` expected");
return null;
}
mixin(tokenCheck!";");
Expand Down Expand Up @@ -3931,7 +3931,7 @@ class Parser
mixin(parseNodeQ!(`node.mixinExpression`, `MixinExpression`));
else
{
error(`"(" or identifier expected`);
error("`(` or identifier expected");
return null;
}
expect(tok!";");
Expand Down Expand Up @@ -5063,7 +5063,7 @@ class Parser
}
else
{
error(`"switch" expected`);
error("`switch` expected");
return null;
}
case tok!"debug":
Expand All @@ -5087,7 +5087,7 @@ class Parser
mixin(parseNodeQ!(`node.staticForeachStatement`, `StaticForeachStatement`));
else
{
error("'if' or 'assert' or 'foreach' or 'foreach_reverse' expected.");
error("`if`, `assert`, `foreach` or `foreach_reverse` expected.");
return null;
}
break;
Expand Down Expand Up @@ -6121,7 +6121,7 @@ class Parser
goto default;
default:
if (validate)
error(`"const", "immutable", "inout", or "shared" expected`);
error("`const`, `immutable`, `inout`, or `shared` expected");
return tok!"";
}
}
Expand Down Expand Up @@ -6264,7 +6264,7 @@ class Parser
ownArray(node.memberFunctionAttributes, memberFunctionAttributes);
return node;
default:
error(`"*", "[", "delegate", or "function" expected.`);
error("`*`, `[`, `delegate`, or `function` expected.");
return null;
}
}
Expand Down Expand Up @@ -6639,7 +6639,7 @@ class Parser
node.token = advance();
else
{
error(`Expected an integer literal, an identifier, "assert", or "unittest"`);
error("Expected an integer literal, an identifier, `assert`, or `unittest`");
return null;
}
expect(tok!")");
Expand Down Expand Up @@ -7387,7 +7387,7 @@ protected:
auto token = (index < tokens.length
? (tokens[index].text is null ? str(tokens[index].type) : tokens[index].text)
: "EOF");
error("Expected " ~ tokenString ~ " instead of " ~ token,
error("Expected `" ~ tokenString ~ "` instead of `" ~ token ~ "`",
!shouldNotAdvance);
return null;
}
Expand Down Expand Up @@ -7646,7 +7646,7 @@ protected:
goto emptyBody;
else
{
error("Struct body or ';' expected");
error("Struct body or `;` expected");
return null;
}
}
Expand Down

0 comments on commit 1b0df8c

Please sign in to comment.