commit e46629b68032614b066a7f7bd3ed1b3aa6b23c34
parent 47c4faf7188d035bd7d9bc78f84ab6aad62f0f44
Author: Drew DeVault <sir@cmpwn.com>
Date: Tue, 5 Oct 2021 14:21:30 +0200
haredoc: fix issues with new tokens
hare::parse didn't grok @hidden and haredoc didn't grok 'type' builtins
Signed-off-by: Drew DeVault <sir@cmpwn.com>
Diffstat:
5 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/cmd/haredoc/html.ha b/cmd/haredoc/html.ha
@@ -456,6 +456,8 @@ fn builtin_type(b: ast::builtin_type) str = {
return "uintptr";
case ast::builtin_type::VOID =>
return "void";
+ case ast::builtin_type::TYPE =>
+ return "type";
};
};
diff --git a/hare/ast/decl.ha b/hare/ast/decl.ha
@@ -15,6 +15,7 @@ export type decl_const = struct {
// const foo: int = 0;
export type decl_global = struct {
is_const: bool,
+ is_hidden: bool,
symbol: str,
ident: ident,
_type: _type,
diff --git a/hare/lex/token.ha b/hare/lex/token.ha
@@ -6,6 +6,7 @@ export type ltok = enum uint {
// Keep ordered with bmap
// Alpha sorted
ATTR_FINI,
+ ATTR_HIDDEN,
ATTR_INIT,
ATTR_NORETURN,
ATTR_OFFSET,
@@ -152,6 +153,7 @@ export type ltok = enum uint {
const bmap: [_]str = [
// Keep ordered with tok
"@fini",
+ "@hidden",
"@init",
"@noreturn",
"@offset",
diff --git a/hare/parse/decl.ha b/hare/parse/decl.ha
@@ -64,6 +64,7 @@ fn decl_global(
case lex::token =>
yield attr_symbol(lexer)?;
};
+ const hidden = try(lexer, ltok::ATTR_HIDDEN)? is lex::token;
const ident = ident(lexer)?;
want(lexer, ltok::COLON)?;
const _type = _type(lexer)?;
@@ -77,6 +78,7 @@ fn decl_global(
const btok = try(lexer, ltok::COMMA)?;
append(decl, ast::decl_global {
is_const = tok == ltok::CONST,
+ is_hidden = hidden,
symbol = symbol,
ident = ident,
_type = _type,
diff --git a/scripts/gen-docs b/scripts/gen-docs
@@ -1,7 +1,7 @@
#!/bin/sh
# Yes, I am entirely aware that this is a hack
modules=$(awk '
-/^modules="/ { sub(/.*=\"/, ""); print $1; mods = 1 }
+/^modules="/ { sub(/.*="/, ""); print $1; mods = 1 }
/^[a-z][a-z0-9:_]+$/ { if (mods == 1) { print $1 } }
/^[a-z][a-z0-9:_]+"$/ { if (mods == 1) { mods = 0; sub(/"/, ""); print $1 } }
' < scripts/gen-stdlib)