-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
80 changed files
with
419 additions
and
824 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,8 @@ | ||
using MrKWatkins.Ast; | ||
using Socordia.CodeAnalysis.Parsing; | ||
|
||
namespace Socordia.CodeAnalysis.AST; | ||
|
||
public class AstNode : PropertyNode<AstNode> | ||
{ | ||
public AstNode WithRange(Token keywordToken, Token iteratorPrev) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public AstNode WithRange(Token token) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
NewSource/Socordia.CodeAnalysis/AST/Declarations/ClassDeclaration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Socordia.CodeAnalysis.AST.Declarations; | ||
|
||
public class ClassDeclaration : Declaration | ||
{ | ||
public ClassDeclaration(string name, List<AstNode> inheritances, List<AstNode> members) | ||
{ | ||
Properties.Set(nameof(Name), name); | ||
Properties.Set(nameof(Inheritances), inheritances); | ||
Children.Add(members); | ||
} | ||
|
||
public string Name => Properties.GetOrThrow<string>(nameof(Name)); | ||
public List<AstNode> Inheritances => Properties.GetOrThrow<List<AstNode>>(nameof(Inheritances)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Socordia.CodeAnalysis.AST.Expressions; | ||
|
||
public class Call : AstNode | ||
{ | ||
public Call(AstNode callee, List<AstNode> arguments) | ||
{ | ||
Children.Add(callee); | ||
Children.Add(arguments); | ||
} | ||
|
||
public AstNode Callee => Children[0]; | ||
public IEnumerable<AstNode> Arguments => Children.Skip(1); | ||
} |
9 changes: 9 additions & 0 deletions
9
NewSource/Socordia.CodeAnalysis/AST/Expressions/CollectionExpression.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Socordia.CodeAnalysis.AST.Expressions; | ||
|
||
public class CollectionExpression : AstNode | ||
{ | ||
public CollectionExpression(List<AstNode> elements) | ||
{ | ||
Children.Add(elements); | ||
} | ||
} |
15 changes: 11 additions & 4 deletions
15
NewSource/Socordia.CodeAnalysis/AST/Expressions/UnaryOperator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
using Loyc; | ||
namespace Socordia.CodeAnalysis.AST.Expressions; | ||
|
||
namespace Socordia.CodeAnalysis.AST.Expressions; | ||
public enum UnaryOperatorKind | ||
{ | ||
Prefix, | ||
Suffix | ||
} | ||
|
||
public class UnaryOperator : AstNode | ||
{ | ||
public UnaryOperator(Symbol op, AstNode operand) | ||
public UnaryOperator(string op, AstNode operand, UnaryOperatorKind kind) | ||
{ | ||
Properties.Set(nameof(Op), op); | ||
Properties.Set(nameof(Kind), kind); | ||
|
||
Children.Add(operand); | ||
} | ||
|
||
public Symbol Op => Properties.GetOrThrow<Symbol>(nameof(Op)); | ||
public string Op => Properties.GetOrThrow<string>(nameof(Op)); | ||
public UnaryOperatorKind Kind => Properties.GetOrThrow<UnaryOperatorKind>(nameof(Kind)); | ||
public AstNode Operand => Children.First; | ||
} |
6 changes: 0 additions & 6 deletions
6
NewSource/Socordia.CodeAnalysis/AST/Statements/BreakStatement.cs
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
NewSource/Socordia.CodeAnalysis/AST/Statements/ContinueStatement.cs
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
NewSource/Socordia.CodeAnalysis/AST/Statements/Loops/BreakStatement.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Socordia.CodeAnalysis.AST.Statements.Loops; | ||
|
||
public class BreakStatement : AstNode | ||
{ | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
NewSource/Socordia.CodeAnalysis/AST/Statements/Loops/ContinueStatement.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Socordia.CodeAnalysis.AST.Statements.Loops; | ||
|
||
public class ContinueStatement : AstNode | ||
{ | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...alysis/AST/Statements/DoWhileStatement.cs → .../AST/Statements/Loops/DoWhileStatement.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
NewSource/Socordia.CodeAnalysis/AST/Statements/Loops/ForStatement.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace Socordia.CodeAnalysis.AST.Statements.Loops; | ||
|
||
public class ForStatement : AstNode | ||
{ | ||
public ForStatement(AstNode varExpr, AstNode type, AstNode arr, Block body) | ||
{ | ||
Children.Add(varExpr); | ||
Children.Add(type); | ||
Children.Add(arr); | ||
Children.Add(body); | ||
} | ||
|
||
public AstNode VarExpr => Children[0]; | ||
public AstNode Type => Children[1]; | ||
public AstNode Arr => Children[2]; | ||
public Block Body => (Block) Children[3]; | ||
} |
2 changes: 1 addition & 1 deletion
2
...Analysis/AST/Statements/WhileStatement.cs → ...is/AST/Statements/Loops/WhileStatement.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Socordia.CodeAnalysis.AST; | ||
|
||
public class TypeAlias : AstNode | ||
{ | ||
public TypeAlias(AstNode expr) | ||
{ | ||
Children.Add(expr); | ||
} | ||
|
||
public AstNode Expression => Children[0]; | ||
} |
11 changes: 11 additions & 0 deletions
11
NewSource/Socordia.CodeAnalysis/AST/TypeNames/GenericTypeName.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Socordia.CodeAnalysis.AST.TypeNames; | ||
|
||
public class GenericTypeName : SimpleTypeName | ||
{ | ||
public GenericTypeName(string name, List<TypeName> genericArguments) : base(name) | ||
{ | ||
Properties.Set(nameof(GenericArguments), genericArguments); | ||
} | ||
|
||
public List<TypeName> GenericArguments => Properties.GetOrThrow<List<TypeName>>(nameof(GenericArguments)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Socordia.CodeAnalysis.AST.TypeNames; | ||
|
||
public enum PointerKind | ||
{ | ||
Transient, | ||
Reference | ||
} |
37 changes: 37 additions & 0 deletions
37
NewSource/Socordia.CodeAnalysis/AST/TypeNames/PointerTypeName.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Text; | ||
using Socordia.CodeAnalysis.Parsing; | ||
|
||
namespace Socordia.CodeAnalysis.AST.TypeNames; | ||
|
||
public class PointerTypeName : TypeName | ||
{ | ||
public PointerTypeName(TypeName type, PointerKind kind) | ||
{ | ||
Children.Add(type); | ||
Properties.Set(nameof(Kind), kind); | ||
} | ||
|
||
public TypeName Type => (TypeName)Children[0]; | ||
public PointerKind Kind => Properties.GetOrThrow<PointerKind>(nameof(Kind)); | ||
|
||
public override string ToString() | ||
{ | ||
var builder = new StringBuilder(); | ||
|
||
switch (Kind) | ||
{ | ||
case PointerKind.Transient: | ||
builder.Append('*'); | ||
break; | ||
case PointerKind.Reference: | ||
builder.Append('&'); | ||
break; | ||
default: | ||
throw new ArgumentOutOfRangeException(); | ||
} | ||
|
||
builder.Append(Type); | ||
|
||
return builder.ToString(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
NewSource/Socordia.CodeAnalysis/AST/TypeNames/SimpleTypeName.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Socordia.CodeAnalysis.AST.TypeNames; | ||
|
||
public class SimpleTypeName : TypeName | ||
{ | ||
public SimpleTypeName(string name) | ||
{ | ||
Properties.Set(nameof(Name), name); | ||
} | ||
|
||
public string Name => Properties.GetOrThrow<string>(nameof(Name)); | ||
|
||
public override string ToString() => Name; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Socordia.CodeAnalysis.AST.TypeNames; | ||
|
||
public abstract class TypeName : AstNode | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using Loyc.Syntax; | ||
using Socordia.CodeAnalysis.Parsing.ParsePoints; | ||
|
||
namespace Socordia.CodeAnalysis.Parsing; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.