more implementation work
This commit is contained in:
parent
6dc1e4c2ff
commit
3a66f01405
16
std/d/ast.d
16
std/d/ast.d
|
@ -238,8 +238,7 @@ interface ASTNode
|
||||||
/** */ void accept(ASTVisitor visitor);
|
/** */ void accept(ASTVisitor visitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
immutable string DEFAULT_ACCEPT = q{void accept(ASTVisitor visitor) { visitor.visit(this); }};
|
immutable string DEFAULT_ACCEPT = q{void accept(ASTVisitor visitor) {}};
|
||||||
|
|
||||||
|
|
||||||
immutable string SHIFT_SHIFT_BODY = q{
|
immutable string SHIFT_SHIFT_BODY = q{
|
||||||
/** */ Token operator;
|
/** */ Token operator;
|
||||||
|
@ -577,7 +576,16 @@ public:
|
||||||
class AttributedDeclaration : ASTNode
|
class AttributedDeclaration : ASTNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
mixin(DEFAULT_ACCEPT);
|
override void accept(ASTVisitor visitor)
|
||||||
|
{
|
||||||
|
if (attribute !is null)
|
||||||
|
visitor.visit(attribute);
|
||||||
|
foreach (dec; declarations)
|
||||||
|
{
|
||||||
|
if (dec !is null)
|
||||||
|
visitor.visit(dec);
|
||||||
|
}
|
||||||
|
}
|
||||||
/** */Attribute attribute;
|
/** */Attribute attribute;
|
||||||
/** */Declaration[] declarations;
|
/** */Declaration[] declarations;
|
||||||
}
|
}
|
||||||
|
@ -848,6 +856,7 @@ public:
|
||||||
if (sharedStaticConstructor !is null) visitor.visit(sharedStaticConstructor);
|
if (sharedStaticConstructor !is null) visitor.visit(sharedStaticConstructor);
|
||||||
if (conditionalDeclaration !is null) visitor.visit(conditionalDeclaration);
|
if (conditionalDeclaration !is null) visitor.visit(conditionalDeclaration);
|
||||||
if (pragmaDeclaration !is null) visitor.visit(pragmaDeclaration);
|
if (pragmaDeclaration !is null) visitor.visit(pragmaDeclaration);
|
||||||
|
if (versionSpecification !is null) visitor.visit(versionSpecification);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */ AttributedDeclaration attributedDeclaration;
|
/** */ AttributedDeclaration attributedDeclaration;
|
||||||
|
@ -873,6 +882,7 @@ public:
|
||||||
/** */ SharedStaticConstructor sharedStaticConstructor;
|
/** */ SharedStaticConstructor sharedStaticConstructor;
|
||||||
/** */ ConditionalDeclaration conditionalDeclaration;
|
/** */ ConditionalDeclaration conditionalDeclaration;
|
||||||
/** */ PragmaDeclaration pragmaDeclaration;
|
/** */ PragmaDeclaration pragmaDeclaration;
|
||||||
|
/** */ VersionSpecification versionSpecification;
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
|
@ -1344,7 +1344,7 @@ class ClassFour(A, B) if (someTest()) : Super {}};
|
||||||
ConditionalDeclaration parseConditionalDeclaration()
|
ConditionalDeclaration parseConditionalDeclaration()
|
||||||
{
|
{
|
||||||
auto node = new ConditionalDeclaration;
|
auto node = new ConditionalDeclaration;
|
||||||
// TODO
|
node.compileCondition = parseCompileCondition();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1586,6 +1586,16 @@ class ClassFour(A, B) if (someTest()) : Super {}};
|
||||||
node.variableDeclaration = parseVariableDeclaration(type);
|
node.variableDeclaration = parseVariableDeclaration(type);
|
||||||
break;
|
break;
|
||||||
case TokenType.version_:
|
case TokenType.version_:
|
||||||
|
if (peekIs(TokenType.lParen))
|
||||||
|
node.conditionalDeclaration = parseConditionalDeclaration();
|
||||||
|
else if (peekIs(TokenType.assign))
|
||||||
|
node.versionSpecification = parseVersionSpecification();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error(`"=" or "(" expected following "version"`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case TokenType.debug_:
|
case TokenType.debug_:
|
||||||
node.conditionalDeclaration = parseConditionalDeclaration();
|
node.conditionalDeclaration = parseConditionalDeclaration();
|
||||||
break;
|
break;
|
||||||
|
@ -2982,6 +2992,12 @@ interface "Four"
|
||||||
{
|
{
|
||||||
auto node = new NonVoidInitializer;
|
auto node = new NonVoidInitializer;
|
||||||
// TODO
|
// TODO
|
||||||
|
if (curentIs(TokenType.lBrace))
|
||||||
|
node.structInitializer = parseStructInitializer()
|
||||||
|
else if (currentIs(TokenType.lBracket))
|
||||||
|
node.arrayInitializer = parseArrayInitializer()
|
||||||
|
else
|
||||||
|
node.assignExpression = parseAssignExpression();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3025,7 +3041,8 @@ interface "Four"
|
||||||
OrOrExpression parseOrOrExpression()
|
OrOrExpression parseOrOrExpression()
|
||||||
{
|
{
|
||||||
auto node = new OrOrExpression;
|
auto node = new OrOrExpression;
|
||||||
// TODO
|
node.andAndExpression = parseAndAndExpression();
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3525,8 +3542,12 @@ interface "Four"
|
||||||
{
|
{
|
||||||
auto node = new StructBody;
|
auto node = new StructBody;
|
||||||
expect(TokenType.lBrace);
|
expect(TokenType.lBrace);
|
||||||
while (tokens[index] != TokenType.rBrace && moreTokens())
|
version (development)
|
||||||
node.structBodyItems ~= parseStructBodyItem();
|
skipBraceContent();
|
||||||
|
else
|
||||||
|
assert (0);
|
||||||
|
//while (tokens[index] != TokenType.rBrace && moreTokens())
|
||||||
|
// node.structBodyItems ~= parseStructBodyItem();
|
||||||
expect(TokenType.rBrace);
|
expect(TokenType.rBrace);
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
@ -3967,9 +3988,9 @@ interface "Four"
|
||||||
{
|
{
|
||||||
auto node = new TernaryExpression;
|
auto node = new TernaryExpression;
|
||||||
node.orOrExpression = parseOrOrExpression();
|
node.orOrExpression = parseOrOrExpression();
|
||||||
if (tokens[index] == TokenType.ternary)
|
if (currentIs(TokenType.ternary))
|
||||||
{
|
{
|
||||||
++index;
|
advance();
|
||||||
node.expression = parseExpression();
|
node.expression = parseExpression();
|
||||||
expect(TokenType.colon);
|
expect(TokenType.colon);
|
||||||
node.ternaryExpression = parseTernaryExpression();
|
node.ternaryExpression = parseTernaryExpression();
|
||||||
|
|
|
@ -33,6 +33,17 @@ class TestVisitor : ASTVisitor
|
||||||
writeln("import declaration found");
|
writeln("import declaration found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override void visit(InterfaceDeclaration intDec)
|
||||||
|
{
|
||||||
|
writeln("Interface ", intDec.identifier.value,
|
||||||
|
" on line ", intDec.identifier.line);
|
||||||
|
}
|
||||||
|
|
||||||
|
override void visit(VersionSpecification verSpec)
|
||||||
|
{
|
||||||
|
writeln("Version specification");
|
||||||
|
}
|
||||||
|
|
||||||
alias ASTVisitor.visit visit;
|
alias ASTVisitor.visit visit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue