-
Notifications
You must be signed in to change notification settings - Fork 7
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
1 parent
ba2b237
commit 93996d4
Showing
5 changed files
with
146 additions
and
3 deletions.
There are no files selected for viewing
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,26 @@ | ||
|
||
public class SourceLocation { | ||
let mut line: u32; | ||
let mut column: u32; | ||
let mut width: u32; | ||
let mut filename: String; | ||
|
||
public: SourceLocation() : | ||
line(0), | ||
column(0), | ||
width(0), | ||
filename("") | ||
{} | ||
SourceLocation(line: u32, column: u32, width: u32, filename: String) : | ||
line(line), | ||
column(column), | ||
width(width), | ||
filename(filename) | ||
{} | ||
@inline func get_line() u32 { return self.line; } | ||
@inline func get_column() u32 { return self.column; } | ||
@inline func get_width() u32 { return self.width; } | ||
@inline func get_filename() String { return self.filename; } | ||
} |
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,110 @@ | ||
|
||
import std::opt::{Option}; | ||
import pkg::ast::location::{Location}; | ||
|
||
public enum BinaryOp { | ||
Add, | ||
Sub, | ||
Mul, | ||
Div, | ||
Mod, | ||
Eq, | ||
Ne, | ||
Lt, | ||
Le, | ||
Gt, | ||
Ge, | ||
And, | ||
Or, | ||
New, | ||
Del, | ||
}; | ||
|
||
public class AstType { | ||
let ast: Node; | ||
|
||
public: AstType(Node ast) { | ||
self.ast = ast; | ||
} | ||
|
||
func get_ast() Node { | ||
return self.ast; | ||
} | ||
} | ||
|
||
public class GenericDecl { | ||
let name: String; | ||
let impls: Vector<AstType>; | ||
|
||
public: GenericDecl(String name, Vector<AstType> impls) { | ||
self.name = name; | ||
self.impls = impls; | ||
} | ||
|
||
func get_name() String { | ||
return self.name; | ||
} | ||
|
||
func get_impls() Vector<AstType> { | ||
return self.impls; | ||
} | ||
} | ||
|
||
public class ClassMember { | ||
let name: String; | ||
let ty: AstType; | ||
|
||
public: ClassMember(String name, AstType ty) { | ||
self.name = name; | ||
self.ty = ty; | ||
} | ||
|
||
func get_name() String { | ||
return self.name; | ||
} | ||
|
||
func get_ty() AstType { | ||
return self.ty; | ||
} | ||
} | ||
|
||
public enum AST { | ||
Return(Option<Node>), | ||
Break, | ||
Continue, | ||
If(Node, Node, Vector<Node>), | ||
While(Node, Vector<Node>, /* is_do_while */ bool), | ||
For(Node, Node, Node, Vector<Node>), | ||
Block(Vector<Node>), | ||
Assign(Node, Node), | ||
Call(Node, Vector<Node>), | ||
BinaryOp(BinaryOp, Node, Node, /* is_unary */ bool), | ||
FuncDef(Option<Node>, Vector<Node>, Vector<Node>, Vector<GenericDecl>), | ||
VarDef(Option<Node>, Node), | ||
Ident(String, Vector<AstType>), | ||
Int(i64), | ||
Float(f64), | ||
String(String), | ||
Bool(bool), | ||
ClassDef(Option<Node>, Vector<ClassMember>, Vector<GenericDecl>), | ||
ClassInit(AstType, Vector<Node>), | ||
ClassAccess(Node, String), | ||
NamespaceDef(Option<Node>, Vector<Node>), | ||
NamespaceAccess(Node, String), | ||
Import(Node), | ||
InterfaceDef(Option<Node>, Vector<Node>, Vector<GenericDecl>), | ||
EnumDef(Option<Node>, Vector<Node>), | ||
}; | ||
|
||
public class Node { | ||
let kind: AST; | ||
let location | ||
|
||
public: Node(AST kind) { | ||
self.kind = kind; | ||
} | ||
|
||
@inline func get_kind() AST { | ||
return self.kind; | ||
} | ||
} |
Empty file.
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,4 @@ | ||
|
||
public func main() i32 { | ||
return 0; | ||
} |