-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Description
Either by using the visitor interface or serializing a whole module, we can see AtAttributes are being parsed (as are access specifiers) but they don't seem to be attached to FunctionDeclaration classes. I could be doing something wrong here, but as far as I can tell it is impossible to get attributes of functions without keeping your own track of the whole module separately
/+dub.sdl:
dependency "libdparse" version="~>0.9"
+/
import dparse.ast;
import std.stdio;
import dparse.lexer;
class TestVisitor : ASTVisitor
{
alias visit = ASTVisitor.visit;
override void visit(const FunctionDeclaration decl)
{
decl.name.text.writeln;
decl.attributes.writeln; //empty?
decl.memberFunctionAttributes.writeln;
decl.accept(this);
}
override void visit(const AtAttribute decl)
{
writeln("wtf");
}
}
void main()
{
import dparse.lexer;
import dparse.parser : parseModule;
import dparse.rollback_allocator : RollbackAllocator;
import std.array : array;
import std.string : representation;
auto sourceCode = q{
public @safe @wow pure void foo(int x)
{
pragma(msg, "dumb");
}
class test {
private const void functor()
{
}
}
}.dup;
LexerConfig config;
auto cache = StringCache(StringCache.defaultBucketCount);
auto tokens = getTokensForParser(sourceCode.representation, config, &cache);
RollbackAllocator rba;
auto m = parseModule(tokens.array, "test.d", &rba);
auto visitor = new TestVisitor();
visitor.visit(m);
}
Metadata
Metadata
Assignees
Labels
No labels