commit 9fac6cad880890de5a7233388e957531d0bfe7ee
parent 7cb3a253f43c12a746be2f377ff420ca4d2734dd
Author: Drew DeVault <sir@cmpwn.com>
Date: Thu, 25 Feb 2021 20:05:53 -0500
hare::ast: reverse order of ast::ident
Diffstat:
3 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/hare/ast/types.ha b/hare/ast/types.ha
@@ -1,5 +1,4 @@
-// Identifies a single object, e.g. foo::bar::baz, ordered from least to most
-// significant part (foo::bar::baz becomes ["baz", "bar", "foo"].
+// Identifies a single object, e.g. foo::bar::baz.
export type ident = []str;
// Maximum length of an identifier, as the sum of the lengths of its parts plus
diff --git a/hare/parse/+test.ha b/hare/parse/+test.ha
@@ -24,7 +24,7 @@ use strings;
let ident = ident(&lexer) as ast::ident;
defer ast::ident_free(ident);
assert(len(ident) == 2);
- assert(ident[0] == "bar" && ident[1] == "foo");
+ assert(ident[0] == "foo" && ident[1] == "bar");
assert(lex::lex(&lexer) is io::EOF);
};
@@ -35,8 +35,8 @@ use strings;
let ident = ident(&lexer) as ast::ident;
defer ast::ident_free(ident);
assert(len(ident) == 3);
- assert(ident[0] == "baz" && ident[1] == "bar"
- && ident[2] == "foo");
+ assert(ident[0] == "foo" && ident[1] == "bar"
+ && ident[2] == "baz");
assert(lex::lex(&lexer) is io::EOF);
};
@@ -47,7 +47,7 @@ use strings;
let ident = ident(&lexer) as ast::ident;
defer ast::ident_free(ident);
assert(len(ident) == 2);
- assert(ident[0] == "bar" && ident[1] == "foo");
+ assert(ident[0] == "foo" && ident[1] == "bar");
let tok = lex::lex(&lexer) as (lex::token, lex::location);
assert(tok.0 as lex::btoken == lex::btoken::SEMICOLON);
};
@@ -85,7 +85,7 @@ use strings;
};
assert(len(mods) == 3);
- let expected: [_][]str = [["foo"], ["bar"], ["bat", "baz"]];
+ let expected: [_][]str = [["foo"], ["bar"], ["baz", "bat"]];
for (let i = 0z; i < len(mods); i += 1) {
assert(mods[i] is ast::import_module);
@@ -117,7 +117,7 @@ use strings;
let expected: [_](str, []str) = [
("foo", ["bar"]),
("baz", ["bat"]),
- ("qux", ["corge", "quux"])
+ ("qux", ["quux", "corge"])
];
for (let i = 0z; i < len(mods); i += 1) {
@@ -148,7 +148,7 @@ use strings;
let expected: [_]([]str, []str) = [
(["foo"], ["bar"]),
(["baz"], ["bat", "qux"]),
- (["corge", "quux"], ["grault", "garply"])
+ (["quux", "corge"], ["grault", "garply"])
];
for (let i = 0z; i < len(mods); i += 1) {
diff --git a/hare/parse/parse.ha b/hare/parse/parse.ha
@@ -9,10 +9,7 @@ fn ident_trailing(lexer: *lex::lexer) ((ast::ident, bool) | error) = {
for (true) {
let name = match (try_name(lexer)?) {
n: lex::name => n,
- void => {
- slice::reverse(ident, size(ast::ident));
- return (ident: ast::ident, true);
- },
+ void => return (ident: ast::ident, true),
};
append(ident, name: str);
z += len(name);
@@ -27,7 +24,6 @@ fn ident_trailing(lexer: *lex::lexer) ((ast::ident, bool) | error) = {
return syntaxerr(mkloc(lexer),
"Identifier exceeds maximum length");
};
- slice::reverse(ident, size(ast::ident));
return (ident: ast::ident, false);
};