Skip to content
Permalink
Browse files

support descending into trivial mixins and reading dox

  • Loading branch information
adamdruppe committed Oct 19, 2019
1 parent 733a19f commit 944beaba406433e55460759f4d22d3dcb0e9edc4
Showing with 5,563 additions and 527 deletions.
  1. +6 −0 Dscanner/libdparse/src/dparse/ast.d
  2. +36 −3 Dscanner/libdparse/src/dparse/parser.d
  3. +1 −1 Makefile
  4. +5,383 −518 cgi.d
  5. +4 −0 doc2.d
  6. +18 −1 jsvar.d
  7. +71 −2 locate.d
  8. +44 −2 script.d
@@ -2144,9 +2144,15 @@ public:
override void accept(ASTVisitor visitor) const
{
mixin(visitIfNotNull!(mixinExpression, templateMixinExpression));
foreach(decl; trivialDeclarations) {
decl.accept(visitor);
}
}
/** */ MixinExpression mixinExpression;
/** */ TemplateMixinExpression templateMixinExpression;

Declaration[] trivialDeclarations;

mixin OpEquals;
}

@@ -3933,9 +3933,36 @@ class Parser
auto node = allocate!MixinDeclaration;
if (peekIsOneOf(tok!"identifier", tok!"typeof", tok!"."))
mixin(nullCheck!`node.templateMixinExpression = parseTemplateMixinExpression()`);
else if (peekIs(tok!"("))
else if (peekIs(tok!"(")) {
mixin(nullCheck!`node.mixinExpression = parseMixinExpression()`);
else

if(auto ae = cast(UnaryExpression) node.mixinExpression.assignExpression) {
auto pe = ae.primaryExpression;
if(pe) {
auto txt = pe.primary.text;
if(txt.length > 5 && txt[0 .. 2] == "q{") {
txt = txt[2 .. $-1];

LexerConfig config;
StringCache* stringCache = new StringCache(128);

config.stringBehavior = StringBehavior.source;
config.whitespaceBehavior = WhitespaceBehavior.include;
config.fileName = "mixin";

auto tokens = getTokensForParser(cast(ubyte[]) txt, config, stringCache);

foreach(ref token; tokens) {
cast() token.line += pe.primary.line - 1;
}
auto m = .parseModule(tokens, "mixin");
node.trivialDeclarations = m.declarations.dup;
}
}
}

//node.trivialDeclarations = parseDeclaration
} else
{
error(`"(" or identifier expected`);
return null;
@@ -3957,7 +3984,13 @@ class Parser
auto node = allocate!MixinExpression;
expect(tok!"mixin");
expect(tok!"(");
mixin(nullCheck!`node.assignExpression = parseAssignExpression()`);
moar:
// FIXME: it discards the others...
mixin(nullCheck!`node.assignExpression = parseAssignExpression()`);
if (currentIs(tok!",")) {
advance();
goto moar;
}
expect(tok!")");
return node;
}
@@ -5,7 +5,7 @@ all:
dmd -m64 doc2.d latex.d cgi.d comment.d stemmer.d dom.d script.d jsvar.d html.d color.d -J. $(LIBDPARSE) -g # -version=std_parser_verbose
#dmd -of/var/www/dpldocs.info/locate locate.d dom.d stemmer.d cgi -J. -version=fastcgi -m64 -debug
locate:
dmd -of/var/www/dpldocs.info/locate locate.d dom.d stemmer.d cgi -J. -version=fastcgi -m64 -debug postgres.d database.d -L-L/usr/local/pgsql/lib
dmd -oflocate locate.d dom.d stemmer.d cgi -J. -version=scgi -m64 -debug postgres.d database.d -L-L/usr/local/pgsql/lib -g

vps_locate:
ldc2 -oq -O3 -m64 locate.d dom.d stemmer.d cgi -J. -d-version=scgi -d-version=vps -g

0 comments on commit 944beab

Please sign in to comment.
You can’t perform that action at this time.