Use new dparse and dsymbol

This commit is contained in:
Hackerpilot 2015-10-29 16:15:03 -07:00
parent a55e93abb3
commit 73ddd29ce2
41 changed files with 114 additions and 116 deletions

View File

@ -10,7 +10,8 @@ SRC := \
$(shell find containers/src -name "*.d")\ $(shell find containers/src -name "*.d")\
$(shell find dsymbol/src -name "*.d")\ $(shell find dsymbol/src -name "*.d")\
$(shell find inifiled/source/ -name "*.d")\ $(shell find inifiled/source/ -name "*.d")\
$(shell find libdparse/src/std/ -name "*.d")\ $(shell find libdparse/src/std/experimental/ -name "*.d")\
$(shell find libdparse/src/dparse/ -name "*.d")\
$(shell find src/ -name "*.d") $(shell find src/ -name "*.d")
INCLUDE_PATHS = \ INCLUDE_PATHS = \
-Iinifiled/source -Isrc\ -Iinifiled/source -Isrc\

View File

@ -6,8 +6,8 @@
module analysis.asm_style; module analysis.asm_style;
import std.stdio; import std.stdio;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import analysis.base; import analysis.base;
import analysis.helpers; import analysis.helpers;
import dsymbol.scope_ : Scope; import dsymbol.scope_ : Scope;

View File

@ -2,7 +2,7 @@ module analysis.base;
import std.container; import std.container;
import std.string; import std.string;
import std.d.ast; import dparse.ast;
import std.array; import std.array;
import dsymbol.scope_ : Scope; import dsymbol.scope_ : Scope;

View File

@ -7,8 +7,8 @@ module analysis.builtin_property_names;
import std.stdio; import std.stdio;
import std.regex; import std.regex;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import analysis.base; import analysis.base;
import analysis.helpers; import analysis.helpers;
import dsymbol.scope_; import dsymbol.scope_;

View File

@ -5,8 +5,8 @@
module analysis.comma_expression; module analysis.comma_expression;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import analysis.base; import analysis.base;
import dsymbol.scope_; import dsymbol.scope_;

View File

@ -1,7 +1,7 @@
module analysis.constructors; module analysis.constructors;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import std.stdio; import std.stdio;
import analysis.base; import analysis.base;
import analysis.helpers; import analysis.helpers;

View File

@ -6,8 +6,8 @@
module analysis.del; module analysis.del;
import std.stdio; import std.stdio;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import analysis.base; import analysis.base;
import analysis.helpers; import analysis.helpers;
import dsymbol.scope_; import dsymbol.scope_;

View File

@ -7,8 +7,8 @@ module analysis.duplicate_attribute;
import std.stdio; import std.stdio;
import std.string; import std.string;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import analysis.base; import analysis.base;
import analysis.helpers; import analysis.helpers;
import dsymbol.scope_ : Scope; import dsymbol.scope_ : Scope;

View File

@ -5,8 +5,8 @@
module analysis.enumarrayliteral; module analysis.enumarrayliteral;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import analysis.base; import analysis.base;
import std.algorithm : canFind; import std.algorithm : canFind;
import dsymbol.scope_ : Scope; import dsymbol.scope_ : Scope;

View File

@ -6,8 +6,8 @@
module analysis.fish; module analysis.fish;
import std.stdio; import std.stdio;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import analysis.base; import analysis.base;
import analysis.helpers; import analysis.helpers;
import dsymbol.scope_ : Scope; import dsymbol.scope_ : Scope;

View File

@ -6,8 +6,8 @@
module analysis.function_attributes; module analysis.function_attributes;
import analysis.base; import analysis.base;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import std.stdio; import std.stdio;
import dsymbol.scope_; import dsymbol.scope_;

View File

@ -9,7 +9,7 @@ import std.string;
import std.traits; import std.traits;
import std.stdio; import std.stdio;
import std.d.ast; import dparse.ast;
import analysis.config; import analysis.config;
import analysis.run; import analysis.run;
import analysis.base; import analysis.base;
@ -53,7 +53,7 @@ S after(S)(S value, S separator)
void assertAnalyzerWarnings(string code, const StaticAnalysisConfig config, string file=__FILE__, size_t line=__LINE__) void assertAnalyzerWarnings(string code, const StaticAnalysisConfig config, string file=__FILE__, size_t line=__LINE__)
{ {
import analysis.run : ParseAllocator, parseModule; import analysis.run : ParseAllocator, parseModule;
import std.d.lexer : StringCache; import dparse.lexer : StringCache;
StringCache cache = StringCache(StringCache.defaultBucketCount); StringCache cache = StringCache(StringCache.defaultBucketCount);
ParseAllocator p = new ParseAllocator; ParseAllocator p = new ParseAllocator;

View File

@ -4,9 +4,9 @@
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
module analysis.if_statements; module analysis.if_statements;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import std.d.formatter; import dparse.formatter;
import analysis.base; import analysis.base;
import dsymbol.scope_ : Scope; import dsymbol.scope_ : Scope;
@ -78,7 +78,7 @@ private:
if (expression is null) if (expression is null)
return; return;
auto app = appender!string(); auto app = appender!string();
std.d.formatter.format(app, expression); dparse.formatter.format(app, expression);
immutable size_t prevLocation = alreadyChecked(app.data, line, column); immutable size_t prevLocation = alreadyChecked(app.data, line, column);
if (prevLocation != size_t.max) if (prevLocation != size_t.max)
{ {

View File

@ -6,8 +6,8 @@
module analysis.ifelsesame; module analysis.ifelsesame;
import std.stdio; import std.stdio;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import analysis.base; import analysis.base;
import analysis.helpers; import analysis.helpers;
import dsymbol.scope_ : Scope; import dsymbol.scope_ : Scope;

View File

@ -4,8 +4,8 @@
module analysis.label_var_same_name_check; module analysis.label_var_same_name_check;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import analysis.base; import analysis.base;
import analysis.helpers; import analysis.helpers;

View File

@ -7,8 +7,8 @@ module analysis.length_subtraction;
import std.stdio; import std.stdio;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import analysis.base; import analysis.base;
import analysis.helpers; import analysis.helpers;
import dsymbol.scope_; import dsymbol.scope_;

View File

@ -6,8 +6,8 @@
module analysis.local_imports; module analysis.local_imports;
import std.stdio; import std.stdio;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import analysis.base; import analysis.base;
import analysis.helpers; import analysis.helpers;
import dsymbol.scope_; import dsymbol.scope_;

View File

@ -6,8 +6,8 @@
module analysis.logic_precedence; module analysis.logic_precedence;
import std.stdio; import std.stdio;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import analysis.base; import analysis.base;
import analysis.helpers; import analysis.helpers;
import dsymbol.scope_; import dsymbol.scope_;

View File

@ -3,8 +3,8 @@ module analysis.mismatched_args;
import analysis.base : BaseAnalyzer; import analysis.base : BaseAnalyzer;
import dsymbol.scope_; import dsymbol.scope_;
import dsymbol.symbol; import dsymbol.symbol;
import std.d.ast; import dparse.ast;
import std.d.lexer : tok; import dparse.lexer : tok;
import dsymbol.builtin.names; import dsymbol.builtin.names;
/// Checks for mismatched argument and parameter names /// Checks for mismatched argument and parameter names

View File

@ -7,8 +7,8 @@ module analysis.numbers;
import std.stdio; import std.stdio;
import std.regex; import std.regex;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import analysis.base; import analysis.base;
import analysis.helpers; import analysis.helpers;
import dsymbol.scope_ : Scope; import dsymbol.scope_ : Scope;

View File

@ -7,8 +7,8 @@ module analysis.objectconst;
import std.stdio; import std.stdio;
import std.regex; import std.regex;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import analysis.base; import analysis.base;
import analysis.helpers; import analysis.helpers;
import dsymbol.scope_ : Scope; import dsymbol.scope_ : Scope;

View File

@ -6,8 +6,8 @@
module analysis.opequals_without_tohash; module analysis.opequals_without_tohash;
import std.stdio; import std.stdio;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import analysis.base; import analysis.base;
import analysis.helpers; import analysis.helpers;
import dsymbol.scope_ : Scope; import dsymbol.scope_ : Scope;

View File

@ -6,8 +6,8 @@
module analysis.pokemon; module analysis.pokemon;
import std.stdio; import std.stdio;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import analysis.base; import analysis.base;
import analysis.helpers; import analysis.helpers;
import dsymbol.scope_ : Scope; import dsymbol.scope_ : Scope;

View File

@ -6,8 +6,8 @@
module analysis.range; module analysis.range;
import std.stdio; import std.stdio;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import analysis.base; import analysis.base;
import analysis.helpers; import analysis.helpers;
import dsymbol.scope_ : Scope; import dsymbol.scope_ : Scope;
@ -94,14 +94,14 @@ class BackwardsRangeCheck : BaseAnalyzer
} }
} }
override void visit(const SliceExpression sliceExpression) override void visit(const Index index)
{ {
if (sliceExpression.lower !is null && sliceExpression.upper !is null) if (index.low !is null && index.high !is null)
{ {
state = State.left; state = State.left;
visit(sliceExpression.lower); visit(index.low);
state = State.right; state = State.right;
visit(sliceExpression.upper); visit(index.high);
state = State.ignore; state = State.ignore;
if (hasLeft && hasRight && left > right) if (hasLeft && hasRight && left > right)
{ {
@ -114,7 +114,7 @@ class BackwardsRangeCheck : BaseAnalyzer
hasLeft = false; hasLeft = false;
hasRight = false; hasRight = false;
} }
sliceExpression.accept(this); index.accept(this);
} }
private: private:

View File

@ -5,8 +5,8 @@
module analysis.redundant_parens; module analysis.redundant_parens;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import analysis.base; import analysis.base;
import dsymbol.scope_ : Scope; import dsymbol.scope_ : Scope;

View File

@ -11,9 +11,9 @@ import std.conv;
import std.algorithm; import std.algorithm;
import std.range; import std.range;
import std.array; import std.array;
import std.d.lexer; import dparse.lexer;
import std.d.parser; import dparse.parser;
import std.d.ast; import dparse.ast;
import std.typecons : scoped; import std.typecons : scoped;
import std.experimental.allocator : CAllocatorImpl; import std.experimental.allocator : CAllocatorImpl;
@ -181,7 +181,7 @@ const(Module) parseModule(string fileName, ubyte[] code, ParseAllocator p,
const(Token)[] tokens = getTokensForParser(code, config, &cache); const(Token)[] tokens = getTokensForParser(code, config, &cache);
if (linesOfCode !is null) if (linesOfCode !is null)
(*linesOfCode) += count!(a => isLineOfCode(a.type))(tokens); (*linesOfCode) += count!(a => isLineOfCode(a.type))(tokens);
return std.d.parser.parseModule(tokens, fileName, p, return dparse.parser.parseModule(tokens, fileName, p,
report ? &messageFunctionJSON : &messageFunction, errorCount, warningCount); report ? &messageFunctionJSON : &messageFunction, errorCount, warningCount);
} }

View File

@ -5,8 +5,8 @@
module analysis.stats_collector; module analysis.stats_collector;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import analysis.base; import analysis.base;
class StatsCollector : BaseAnalyzer class StatsCollector : BaseAnalyzer

View File

@ -6,8 +6,8 @@
module analysis.style; module analysis.style;
import std.stdio; import std.stdio;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import std.regex; import std.regex;
import std.array; import std.array;
import std.conv; import std.conv;

View File

@ -7,8 +7,8 @@ module analysis.undocumented;
import analysis.base; import analysis.base;
import dsymbol.scope_ : Scope; import dsymbol.scope_ : Scope;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import std.regex : ctRegex, matchAll; import std.regex : ctRegex, matchAll;
import std.stdio; import std.stdio;

View File

@ -7,13 +7,13 @@ module analysis.unmodified;
import analysis.base; import analysis.base;
import dsymbol.scope_ : Scope; import dsymbol.scope_ : Scope;
import std.container; import std.container;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
/** /**
* Checks for variables that could have been declared const or immutable * Checks for variables that could have been declared const or immutable
*/ */
class UnmodifiedFinder:BaseAnalyzer class UnmodifiedFinder : BaseAnalyzer
{ {
alias visit = BaseAnalyzer.visit; alias visit = BaseAnalyzer.visit;
@ -132,7 +132,6 @@ class UnmodifiedFinder:BaseAnalyzer
mixin PartsMightModify!AsmPrimaryExp; mixin PartsMightModify!AsmPrimaryExp;
mixin PartsMightModify!IndexExpression; mixin PartsMightModify!IndexExpression;
mixin PartsMightModify!SliceExpression;
mixin PartsMightModify!FunctionCallExpression; mixin PartsMightModify!FunctionCallExpression;
mixin PartsMightModify!IdentifierOrTemplateChain; mixin PartsMightModify!IdentifierOrTemplateChain;
mixin PartsMightModify!ReturnStatement; mixin PartsMightModify!ReturnStatement;

View File

@ -4,8 +4,8 @@
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
module analysis.unused; module analysis.unused;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import analysis.base; import analysis.base;
import std.container; import std.container;
import std.regex : Regex, regex, matchAll; import std.regex : Regex, regex, matchAll;
@ -69,7 +69,6 @@ class UnusedVariableCheck : BaseAnalyzer
mixin PartsUseVariables!Initializer; mixin PartsUseVariables!Initializer;
mixin PartsUseVariables!InterfaceDeclaration; mixin PartsUseVariables!InterfaceDeclaration;
mixin PartsUseVariables!NewExpression; mixin PartsUseVariables!NewExpression;
mixin PartsUseVariables!SliceExpression;
mixin PartsUseVariables!StaticIfCondition; mixin PartsUseVariables!StaticIfCondition;
mixin PartsUseVariables!StructDeclaration; mixin PartsUseVariables!StructDeclaration;
mixin PartsUseVariables!TemplateArgumentList; mixin PartsUseVariables!TemplateArgumentList;

View File

@ -4,8 +4,8 @@
module analysis.unused_label; module analysis.unused_label;
import std.d.ast; import dparse.ast;
import std.d.lexer; import dparse.lexer;
import analysis.base; import analysis.base;
import analysis.helpers; import analysis.helpers;
import dsymbol.scope_ : Scope; import dsymbol.scope_ : Scope;

View File

@ -3,9 +3,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at // (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
import std.d.lexer; import dparse.lexer;
import std.d.ast; import dparse.ast;
import std.d.formatter; import dparse.formatter;
import std.stdio; import std.stdio;
import std.string; import std.string;
import std.array; import std.array;
@ -727,25 +727,6 @@ class XMLPrinter : ASTVisitor
output.writeln("</singleImport>"); output.writeln("</singleImport>");
} }
override void visit(const SliceExpression sliceExpression)
{
output.writeln("<sliceExpression>");
visit(sliceExpression.unaryExpression);
if (sliceExpression.lower !is null)
{
output.writeln("<low>");
visit(sliceExpression.lower);
output.writeln("</low>");
}
if (sliceExpression.upper !is null)
{
output.writeln("<high>");
visit(sliceExpression.upper);
output.writeln("</high>");
}
output.writeln("</sliceExpression>");
}
override void visit(const StructDeclaration structDec) override void visit(const StructDeclaration structDec)
{ {
output.writeln("<structDeclaration line=\"", structDec.name.line, "\">"); output.writeln("<structDeclaration line=\"", structDec.name.line, "\">");
@ -970,6 +951,24 @@ class XMLPrinter : ASTVisitor
output.writeln("</xorExpression>"); output.writeln("</xorExpression>");
} }
override void visit(const Index index)
{
output.writeln("<index>");
if (index.high)
{
output.writeln("<low>");
visit(index.low);
output.writeln("<low>");
output.writeln("<high>");
visit(index.high);
output.writeln("<high>");
}
else
visit(index.low);
output.writeln("</index>");
}
override void visit(const AliasInitializer aliasInitializer) { mixin (tagAndAccept!"aliasInitializer"); } override void visit(const AliasInitializer aliasInitializer) { mixin (tagAndAccept!"aliasInitializer"); }
override void visit(const AliasThisDeclaration aliasThisDeclaration) { mixin (tagAndAccept!"aliasThisDeclaration"); } override void visit(const AliasThisDeclaration aliasThisDeclaration) { mixin (tagAndAccept!"aliasThisDeclaration"); }
override void visit(const AnonymousEnumDeclaration anonymousEnumDeclaration) { mixin (tagAndAccept!"anonymousEnumDeclaration"); } override void visit(const AnonymousEnumDeclaration anonymousEnumDeclaration) { mixin (tagAndAccept!"anonymousEnumDeclaration"); }

View File

@ -5,9 +5,9 @@
module ctags; module ctags;
import std.d.parser; import dparse.parser;
import std.d.lexer; import dparse.lexer;
import std.d.ast; import dparse.ast;
import std.algorithm; import std.algorithm;
import std.range; import std.range;
import std.stdio; import std.stdio;
@ -68,7 +68,7 @@ void doNothing(string, size_t, size_t, string, bool)
string paramsToString(Dec)(const Dec dec) string paramsToString(Dec)(const Dec dec)
{ {
import std.d.formatter : Formatter; import dparse.formatter : Formatter;
auto app = appender!string(); auto app = appender!string();
auto formatter = new Formatter!(typeof(app))(app); auto formatter = new Formatter!(typeof(app))(app);

View File

@ -6,9 +6,9 @@
module etags; module etags;
import std.d.parser; import dparse.parser;
import std.d.lexer; import dparse.lexer;
import std.d.ast; import dparse.ast;
import std.algorithm; import std.algorithm;
import std.range; import std.range;
import std.stdio; import std.stdio;
@ -288,7 +288,7 @@ private:
{ {
maketag(name.text, name.index, name.line); maketag(name.text, name.index, name.line);
} }
void maketag(string text, size_t index, ulong line) void maketag(string text, size_t index, ulong line)
{ {
// skip unittests and hidden declarations // skip unittests and hidden declarations

View File

@ -7,7 +7,7 @@ module highlighter;
import std.stdio; import std.stdio;
import std.array; import std.array;
import std.d.lexer; import dparse.lexer;
// http://ethanschoonover.com/solarized // http://ethanschoonover.com/solarized
void highlight(R)(ref R tokens, string fileName) void highlight(R)(ref R tokens, string fileName)

View File

@ -5,7 +5,7 @@
module imports; module imports;
import std.d.ast; import dparse.ast;
import std.stdio; import std.stdio;
import std.container; import std.container;

View File

@ -13,9 +13,9 @@ import std.getopt;
import std.path; import std.path;
import std.stdio; import std.stdio;
import std.range; import std.range;
import std.lexer; import std.experimental.lexer;
import std.d.lexer; import dparse.lexer;
import std.d.parser; import dparse.parser;
import highlighter; import highlighter;
import stats; import stats;

View File

@ -3,9 +3,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at // (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
import std.d.lexer; import dparse.lexer;
import std.d.ast; import dparse.ast;
import std.d.formatter; import dparse.formatter;
import std.stdio; import std.stdio;
import std.string; import std.string;
import std.array; import std.array;

View File

@ -7,7 +7,7 @@ module stats;
import std.stdio; import std.stdio;
import std.algorithm; import std.algorithm;
import std.d.lexer; import dparse.lexer;
pure nothrow bool isLineOfCode(IdType t) pure nothrow bool isLineOfCode(IdType t)
{ {

View File

@ -6,9 +6,9 @@
module symbol_finder; module symbol_finder;
import std.stdio : File; import std.stdio : File;
import std.d.lexer; import dparse.lexer;
import std.d.parser; import dparse.parser;
import std.d.ast; import dparse.ast;
import std.stdio; import std.stdio;
import std.file:isFile; import std.file:isFile;