Remove entity dependency on participle
This commit is contained in:
parent
eab8163cf1
commit
decc5939a1
@ -1,7 +1,7 @@
|
|||||||
package entity
|
package entity
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
import "github.com/alecthomas/participle/v2/lexer"
|
import "git.tebibyte.media/sashakoshka/fspl/errors"
|
||||||
|
|
||||||
// Expression is any construct that can be evaluated.
|
// Expression is any construct that can be evaluated.
|
||||||
type Expression interface {
|
type Expression interface {
|
||||||
@ -22,7 +22,7 @@ type Statement interface {
|
|||||||
// location expression.
|
// location expression.
|
||||||
type Variable struct {
|
type Variable struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Name string `parser:" @Ident "`
|
Name string `parser:" @Ident "`
|
||||||
|
|
||||||
// Semantics
|
// Semantics
|
||||||
@ -41,9 +41,9 @@ func (this *Variable) String () string {
|
|||||||
// assigned to an interface. A declaration is always a valid location
|
// assigned to an interface. A declaration is always a valid location
|
||||||
// expression.
|
// expression.
|
||||||
type Declaration struct {
|
type Declaration struct {
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Name string `parser:" @Ident "`
|
Name string `parser:" @Ident "`
|
||||||
Ty Type `parser:" ':' @@ "`
|
Ty Type `parser:" ':' @@ "`
|
||||||
}
|
}
|
||||||
func (*Declaration) expression(){}
|
func (*Declaration) expression(){}
|
||||||
func (*Declaration) statement(){}
|
func (*Declaration) statement(){}
|
||||||
@ -60,7 +60,7 @@ func (this *Declaration) String () string {
|
|||||||
// expression.
|
// expression.
|
||||||
type Call struct {
|
type Call struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Module string `parser:" (@Ident '::')? "`
|
Module string `parser:" (@Ident '::')? "`
|
||||||
Name string `parser:" '[' @Ident "`
|
Name string `parser:" '[' @Ident "`
|
||||||
Arguments []Expression `parser:" @@* ']' "`
|
Arguments []Expression `parser:" @@* ']' "`
|
||||||
@ -91,7 +91,7 @@ func (this *Call) String () string {
|
|||||||
// A method call is never a valid location expression.
|
// A method call is never a valid location expression.
|
||||||
type MethodCall struct {
|
type MethodCall struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Source *Variable `parser:" @@ '.' "`
|
Source *Variable `parser:" @@ '.' "`
|
||||||
Name string `parser:" '[' @Ident "`
|
Name string `parser:" '[' @Ident "`
|
||||||
Arguments []Expression `parser:" @@* ']' "`
|
Arguments []Expression `parser:" @@* ']' "`
|
||||||
@ -125,9 +125,9 @@ func (this *MethodCall) String () string {
|
|||||||
// valid location expression only if the array being subscripted is.
|
// valid location expression only if the array being subscripted is.
|
||||||
type Subscript struct {
|
type Subscript struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Slice Expression `parser:" '[' '.' @@ "`
|
Slice Expression `parser:" '[' '.' @@ "`
|
||||||
Offset Expression `parser:" @@ ']' "`
|
Offset Expression `parser:" @@ ']' "`
|
||||||
|
|
||||||
// Semantics
|
// Semantics
|
||||||
Ty Type
|
Ty Type
|
||||||
@ -145,10 +145,10 @@ func (this *Subscript) String () string {
|
|||||||
// is operating on. A slice is never a valid location expression.
|
// is operating on. A slice is never a valid location expression.
|
||||||
type Slice struct {
|
type Slice struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Slice Expression `parser:" '[' '\\\\' @@ "`
|
Slice Expression `parser:" '[' '\\\\' @@ "`
|
||||||
Start Expression `parser:" @@? "`
|
Start Expression `parser:" @@? "`
|
||||||
End Expression `parser:" ':' @@? ']' "`
|
End Expression `parser:" ':' @@? ']' "`
|
||||||
}
|
}
|
||||||
func (*Slice) expression(){}
|
func (*Slice) expression(){}
|
||||||
func (*Slice) statement(){}
|
func (*Slice) statement(){}
|
||||||
@ -188,8 +188,8 @@ func (this *Length) String () string {
|
|||||||
// if the pointer being dereferenced is.
|
// if the pointer being dereferenced is.
|
||||||
type Dereference struct {
|
type Dereference struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Pointer Expression `parser:" '[' '.' @@ ']' "`
|
Pointer Expression `parser:" '[' '.' @@ ']' "`
|
||||||
|
|
||||||
// Semantics
|
// Semantics
|
||||||
Ty Type
|
Ty Type
|
||||||
@ -210,8 +210,8 @@ func (this *Dereference) String () string {
|
|||||||
// expression.
|
// expression.
|
||||||
type Reference struct {
|
type Reference struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Value Expression `parser:" '[' '@' @@ ']' "`
|
Value Expression `parser:" '[' '@' @@ ']' "`
|
||||||
|
|
||||||
// Semantics
|
// Semantics
|
||||||
Ty Type
|
Ty Type
|
||||||
@ -227,9 +227,9 @@ func (this *Reference) String () string {
|
|||||||
// contains inherent type information, it may be directly assigned to an
|
// contains inherent type information, it may be directly assigned to an
|
||||||
// interface. A value cast is never a valid location expression.
|
// interface. A value cast is never a valid location expression.
|
||||||
type ValueCast struct {
|
type ValueCast struct {
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Ty Type `parser:" '[' '~' @@ "`
|
Ty Type `parser:" '[' '~' @@ "`
|
||||||
Value Expression `parser:" @@ ']' "`
|
Value Expression `parser:" @@ ']' "`
|
||||||
}
|
}
|
||||||
func (*ValueCast) expression(){}
|
func (*ValueCast) expression(){}
|
||||||
func (*ValueCast) statement(){}
|
func (*ValueCast) statement(){}
|
||||||
@ -243,9 +243,9 @@ func (this *ValueCast) String () string {
|
|||||||
// it may be directly assigned to an interface. A bit cast is never a valid
|
// it may be directly assigned to an interface. A bit cast is never a valid
|
||||||
// location expression.
|
// location expression.
|
||||||
type BitCast struct {
|
type BitCast struct {
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Ty Type `parser:" '[' '~~' @@ "`
|
Ty Type `parser:" '[' '~~' @@ "`
|
||||||
Value Expression `parser:" @@ ']' "`
|
Value Expression `parser:" @@ ']' "`
|
||||||
}
|
}
|
||||||
func (*BitCast) expression(){}
|
func (*BitCast) expression(){}
|
||||||
func (*BitCast) statement(){}
|
func (*BitCast) statement(){}
|
||||||
@ -260,8 +260,8 @@ func (this *BitCast) String () string {
|
|||||||
// be assigned to interfaces. An operation is never a valid location expression.
|
// be assigned to interfaces. An operation is never a valid location expression.
|
||||||
type Operation struct {
|
type Operation struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Operator Operator `parser:" '[' @('++' | '+' | '--' | '-' | '*' | '/' | '%' | '!!' | '||' | '&&' | '^^' | '!' | '|' | '&' | '^' | '<<' | '>>' | '<' | '>' | '<=' | '>=' | '=') "`
|
Operator Operator `parser:" '[' @('++' | '+' | '--' | '-' | '*' | '/' | '%' | '!!' | '||' | '&&' | '^^' | '!' | '|' | '&' | '^' | '<<' | '>>' | '<' | '>' | '<=' | '>=' | '=') "`
|
||||||
Arguments []Expression `parser:" @@+ ']' "`
|
Arguments []Expression `parser:" @@+ ']' "`
|
||||||
|
|
||||||
// Semantics
|
// Semantics
|
||||||
@ -285,8 +285,8 @@ func (this *Operation) String () string {
|
|||||||
// expression.
|
// expression.
|
||||||
type Block struct {
|
type Block struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Steps []Statement `parser:" '{' @@* '}' "`
|
Steps []Statement `parser:" '{' @@* '}' "`
|
||||||
|
|
||||||
// Semantics
|
// Semantics
|
||||||
Ty Type
|
Ty Type
|
||||||
@ -312,9 +312,9 @@ func (this *Block) String () string {
|
|||||||
// struct being accessed is.
|
// struct being accessed is.
|
||||||
type MemberAccess struct {
|
type MemberAccess struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Source *Variable `parser:" @@ "`
|
Source *Variable `parser:" @@ "`
|
||||||
Member string `parser:" '.' @Ident "`
|
Member string `parser:" '.' @Ident "`
|
||||||
|
|
||||||
// Semantics
|
// Semantics
|
||||||
Ty Type
|
Ty Type
|
||||||
@ -333,7 +333,7 @@ func (this *MemberAccess) String () string {
|
|||||||
// expressions. An If/else is never a valid location expression.
|
// expressions. An If/else is never a valid location expression.
|
||||||
type IfElse struct {
|
type IfElse struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Condition Expression `parser:" 'if' @@ "`
|
Condition Expression `parser:" 'if' @@ "`
|
||||||
True Expression `parser:" 'then' @@ "`
|
True Expression `parser:" 'then' @@ "`
|
||||||
False Expression `parser:" ('else' @@)? "`
|
False Expression `parser:" ('else' @@)? "`
|
||||||
@ -361,8 +361,8 @@ func (this *IfElse) String () string {
|
|||||||
// loop's expression is never used. A loop is never a valid location expression.
|
// loop's expression is never used. A loop is never a valid location expression.
|
||||||
type Loop struct {
|
type Loop struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Body Expression `parser:" 'loop' @@ "`
|
Body Expression `parser:" 'loop' @@ "`
|
||||||
|
|
||||||
// Semantics
|
// Semantics
|
||||||
Ty Type
|
Ty Type
|
||||||
@ -378,8 +378,8 @@ func (this *Loop) String () string {
|
|||||||
// to anything. It is never a valid location expression.
|
// to anything. It is never a valid location expression.
|
||||||
type Break struct {
|
type Break struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Value Expression `parser:" '[' 'break' @@? ']' "`
|
Value Expression `parser:" '[' 'break' @@? ']' "`
|
||||||
|
|
||||||
// Semantics
|
// Semantics
|
||||||
Loop *Loop
|
Loop *Loop
|
||||||
@ -401,8 +401,8 @@ func (this *Break) String () string {
|
|||||||
// to anything. A return statement is never a valid location expression.
|
// to anything. A return statement is never a valid location expression.
|
||||||
type Return struct {
|
type Return struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Value Expression `parser:" '[' 'return' @@? ']' "`
|
Value Expression `parser:" '[' 'return' @@? ']' "`
|
||||||
|
|
||||||
// Semantics
|
// Semantics
|
||||||
Declaration TopLevel
|
Declaration TopLevel
|
||||||
@ -423,7 +423,7 @@ func (this *Return) String () string {
|
|||||||
// not be assigned to anything. An assignment statement is never a valid
|
// not be assigned to anything. An assignment statement is never a valid
|
||||||
// location expression.
|
// location expression.
|
||||||
type Assignment struct {
|
type Assignment struct {
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Location Expression `parser:" @@ "`
|
Location Expression `parser:" @@ "`
|
||||||
Value Expression `parser:" '=' @@ "`
|
Value Expression `parser:" '=' @@ "`
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package entity
|
|||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
import "unicode"
|
import "unicode"
|
||||||
import "github.com/alecthomas/participle/v2/lexer"
|
import "git.tebibyte.media/sashakoshka/fspl/errors"
|
||||||
|
|
||||||
// LiteralInt specifies an integer value. It can be assigned to any type that is
|
// LiteralInt specifies an integer value. It can be assigned to any type that is
|
||||||
// derived from an integer or a float, as long as the value fo the literal can
|
// derived from an integer or a float, as long as the value fo the literal can
|
||||||
@ -11,7 +11,7 @@ import "github.com/alecthomas/participle/v2/lexer"
|
|||||||
// be used for this purpose.
|
// be used for this purpose.
|
||||||
type LiteralInt struct {
|
type LiteralInt struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Value int `parser:" @Int "`
|
Value int `parser:" @Int "`
|
||||||
|
|
||||||
// Semantics
|
// Semantics
|
||||||
@ -30,7 +30,7 @@ func (this *LiteralInt) String () string {
|
|||||||
// for this purpose.
|
// for this purpose.
|
||||||
type LiteralFloat struct {
|
type LiteralFloat struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Value float64 `parser:" @Float "`
|
Value float64 `parser:" @Float "`
|
||||||
|
|
||||||
// Semantics
|
// Semantics
|
||||||
@ -60,7 +60,7 @@ func (this *LiteralFloat) String () string {
|
|||||||
// purpose.
|
// purpose.
|
||||||
type LiteralString struct {
|
type LiteralString struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
ValueUTF8 string `parser:" @String "`
|
ValueUTF8 string `parser:" @String "`
|
||||||
ValueUTF16 []uint16
|
ValueUTF16 []uint16
|
||||||
ValueUTF32 []rune
|
ValueUTF32 []rune
|
||||||
@ -94,7 +94,7 @@ func (this *LiteralString) String () string {
|
|||||||
// inherent type information. A value cast may be used for this purpose.
|
// inherent type information. A value cast may be used for this purpose.
|
||||||
type LiteralArray struct {
|
type LiteralArray struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Elements []Expression `parser:" '(' '*' @@* ')' "`
|
Elements []Expression `parser:" '(' '*' @@* ')' "`
|
||||||
|
|
||||||
// Semantics
|
// Semantics
|
||||||
@ -120,8 +120,8 @@ func (this *LiteralArray) String () string {
|
|||||||
// inherent type information. A value cast may be used for this purpose.
|
// inherent type information. A value cast may be used for this purpose.
|
||||||
type LiteralStruct struct {
|
type LiteralStruct struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Members []*Member `parser:" '(' @@* ')' "`
|
Members []*Member `parser:" '(' @@* ')' "`
|
||||||
|
|
||||||
// Semantics
|
// Semantics
|
||||||
Ty Type
|
Ty Type
|
||||||
@ -146,8 +146,8 @@ func (this *LiteralStruct) String () string {
|
|||||||
// value cast may be used for this purpose.
|
// value cast may be used for this purpose.
|
||||||
type LiteralBoolean struct {
|
type LiteralBoolean struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Value *Boolean `parser:" @('true' | 'false') "`
|
Value *Boolean `parser:" @('true' | 'false') "`
|
||||||
|
|
||||||
// Semantics
|
// Semantics
|
||||||
Ty Type
|
Ty Type
|
||||||
@ -172,8 +172,8 @@ func (this *Boolean) Capture (values []string) error {
|
|||||||
|
|
||||||
type LiteralNil struct {
|
type LiteralNil struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Value string `parser:" @'nil' "`
|
Value string `parser:" @'nil' "`
|
||||||
|
|
||||||
// Semantics
|
// Semantics
|
||||||
Ty Type
|
Ty Type
|
||||||
|
@ -2,14 +2,14 @@ package entity
|
|||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
import "strings"
|
import "strings"
|
||||||
import "github.com/alecthomas/participle/v2/lexer"
|
import "git.tebibyte.media/sashakoshka/fspl/errors"
|
||||||
|
|
||||||
// Signature is a function or method signature that is used in functions,
|
// Signature is a function or method signature that is used in functions,
|
||||||
// methods, and specifying interface behaviors. It defines the type of a
|
// methods, and specifying interface behaviors. It defines the type of a
|
||||||
// function.
|
// function.
|
||||||
type Signature struct {
|
type Signature struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Name string `parser:" '[' @Ident "`
|
Name string `parser:" '[' @Ident "`
|
||||||
Arguments []*Declaration `parser:" @@* ']' "`
|
Arguments []*Declaration `parser:" @@* ']' "`
|
||||||
Return Type `parser:" ( ':' @@ )? "`
|
Return Type `parser:" ( ':' @@ )? "`
|
||||||
@ -48,9 +48,9 @@ func (this *Signature) Equals (ty Type) bool {
|
|||||||
// Member is a syntactical construct that is used to list members in struct
|
// Member is a syntactical construct that is used to list members in struct
|
||||||
// literals.
|
// literals.
|
||||||
type Member struct {
|
type Member struct {
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Name string `parser:" @Ident "`
|
Name string `parser:" @Ident "`
|
||||||
Value Expression `parser:" ':' @@ "`
|
Value Expression `parser:" ':' @@ "`
|
||||||
}
|
}
|
||||||
func (this *Member) String () string {
|
func (this *Member) String () string {
|
||||||
return fmt.Sprint(this.Name, ":", this.Value)
|
return fmt.Sprint(this.Name, ":", this.Value)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package entity
|
package entity
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
import "github.com/alecthomas/participle/v2/lexer"
|
import "git.tebibyte.media/sashakoshka/fspl/errors"
|
||||||
|
|
||||||
// TopLevel is any construct that is placed at the root of a file.
|
// TopLevel is any construct that is placed at the root of a file.
|
||||||
type TopLevel interface {
|
type TopLevel interface {
|
||||||
@ -36,7 +36,7 @@ func (this *Access) Capture (values []string) error {
|
|||||||
// Typedef binds a type to a global identifier.
|
// Typedef binds a type to a global identifier.
|
||||||
type Typedef struct {
|
type Typedef struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Acc *Access `parser:" @('-' | '~' | '+')? "`
|
Acc *Access `parser:" @('-' | '~' | '+')? "`
|
||||||
Name string `parser:" @TypeIdent "`
|
Name string `parser:" @TypeIdent "`
|
||||||
Type Type `parser:" ':' @@ "`
|
Type Type `parser:" ':' @@ "`
|
||||||
@ -66,7 +66,7 @@ func (this *Typedef) String () string {
|
|||||||
// these are typed.
|
// these are typed.
|
||||||
type Function struct {
|
type Function struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Acc *Access `parser:" @('-' | '~' | '+')? "`
|
Acc *Access `parser:" @('-' | '~' | '+')? "`
|
||||||
Signature *Signature `parser:" @@ "`
|
Signature *Signature `parser:" @@ "`
|
||||||
LinkName string `parser:" @String? "`
|
LinkName string `parser:" @String? "`
|
||||||
@ -97,7 +97,7 @@ func (this *Function) String () string {
|
|||||||
// unique, but are unique within the type they are defined on.
|
// unique, but are unique within the type they are defined on.
|
||||||
type Method struct {
|
type Method struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Acc *Access `parser:" @('-' | '~' | '+')? "`
|
Acc *Access `parser:" @('-' | '~' | '+')? "`
|
||||||
TypeName string `parser:" @TypeIdent "`
|
TypeName string `parser:" @TypeIdent "`
|
||||||
Signature *Signature `parser:" '.' @@ "`
|
Signature *Signature `parser:" '.' @@ "`
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package entity
|
package entity
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
import "github.com/alecthomas/participle/v2/lexer"
|
import "git.tebibyte.media/sashakoshka/fspl/errors"
|
||||||
|
|
||||||
// Type is any type notation.
|
// Type is any type notation.
|
||||||
type Type interface {
|
type Type interface {
|
||||||
@ -15,10 +15,10 @@ type Type interface {
|
|||||||
|
|
||||||
// TypeNamed refers to a user-defined or built in named type.
|
// TypeNamed refers to a user-defined or built in named type.
|
||||||
type TypeNamed struct {
|
type TypeNamed struct {
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Module string `parser:" (@Ident '::')? "`
|
Module string `parser:" (@Ident '::')? "`
|
||||||
Name string `parser:" @TypeIdent "`
|
Name string `parser:" @TypeIdent "`
|
||||||
Type Type
|
Type Type
|
||||||
}
|
}
|
||||||
func (*TypeNamed) ty(){}
|
func (*TypeNamed) ty(){}
|
||||||
func (this *TypeNamed) String () string {
|
func (this *TypeNamed) String () string {
|
||||||
@ -35,7 +35,7 @@ func (this *TypeNamed) Equals (ty Type) bool {
|
|||||||
|
|
||||||
// TypePointer is a pointer to another type.
|
// TypePointer is a pointer to another type.
|
||||||
type TypePointer struct {
|
type TypePointer struct {
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Referenced Type `parser:" '*' @@ "`
|
Referenced Type `parser:" '*' @@ "`
|
||||||
}
|
}
|
||||||
func (*TypePointer) ty(){}
|
func (*TypePointer) ty(){}
|
||||||
@ -51,8 +51,8 @@ func (this *TypePointer) Equals (ty Type) bool {
|
|||||||
// eachother. Its length is not built into its type and can be changed at
|
// eachother. Its length is not built into its type and can be changed at
|
||||||
// runtime.
|
// runtime.
|
||||||
type TypeSlice struct {
|
type TypeSlice struct {
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Element Type `parser:" '*' ':' @@ "`
|
Element Type `parser:" '*' ':' @@ "`
|
||||||
}
|
}
|
||||||
func (*TypeSlice) ty(){}
|
func (*TypeSlice) ty(){}
|
||||||
func (this *TypeSlice) String () string {
|
func (this *TypeSlice) String () string {
|
||||||
@ -67,9 +67,9 @@ func (this *TypeSlice) Equals (ty Type) bool {
|
|||||||
// length of an array is fixed and is part of its type. Arrays are passed by
|
// length of an array is fixed and is part of its type. Arrays are passed by
|
||||||
// value unless a pointer is used.
|
// value unless a pointer is used.
|
||||||
type TypeArray struct {
|
type TypeArray struct {
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Length int `parser:" @Int "`
|
Length int `parser:" @Int "`
|
||||||
Element Type `parser:" ':' @@ "`
|
Element Type `parser:" ':' @@ "`
|
||||||
}
|
}
|
||||||
func (*TypeArray) ty(){}
|
func (*TypeArray) ty(){}
|
||||||
func (this *TypeArray) String () string {
|
func (this *TypeArray) String () string {
|
||||||
@ -87,8 +87,8 @@ func (this *TypeArray) Equals (ty Type) bool {
|
|||||||
// are specified in. Structs are passed by value unless a pointer is used.
|
// are specified in. Structs are passed by value unless a pointer is used.
|
||||||
type TypeStruct struct {
|
type TypeStruct struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Members []*Declaration `parser:" '(' @@+ ')' "`
|
Members []*Declaration `parser:" '(' @@+ ')' "`
|
||||||
|
|
||||||
// Semantics
|
// Semantics
|
||||||
MemberOrder []string
|
MemberOrder []string
|
||||||
@ -122,7 +122,7 @@ func (this *TypeStruct) Equals (ty Type) bool {
|
|||||||
// pointer to an interface, the pointer's reference will be used instead.
|
// pointer to an interface, the pointer's reference will be used instead.
|
||||||
type TypeInterface struct {
|
type TypeInterface struct {
|
||||||
// Syntax
|
// Syntax
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Behaviors []*Signature `parser:" '(' @@+ ')' "`
|
Behaviors []*Signature `parser:" '(' @@+ ')' "`
|
||||||
|
|
||||||
// Semantics
|
// Semantics
|
||||||
@ -152,9 +152,9 @@ func (this *TypeInterface) Equals (ty Type) bool {
|
|||||||
|
|
||||||
// TypeInt represents any signed or unsigned integer type.
|
// TypeInt represents any signed or unsigned integer type.
|
||||||
type TypeInt struct {
|
type TypeInt struct {
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Width int
|
Width int
|
||||||
Signed bool
|
Signed bool
|
||||||
}
|
}
|
||||||
func (*TypeInt) ty(){}
|
func (*TypeInt) ty(){}
|
||||||
func (this *TypeInt) String () string {
|
func (this *TypeInt) String () string {
|
||||||
@ -171,8 +171,8 @@ func (this *TypeInt) Equals (ty Type) bool {
|
|||||||
|
|
||||||
// TypeFloat represents any floating point type.
|
// TypeFloat represents any floating point type.
|
||||||
type TypeFloat struct {
|
type TypeFloat struct {
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Width int
|
Width int
|
||||||
}
|
}
|
||||||
func (*TypeFloat) ty(){}
|
func (*TypeFloat) ty(){}
|
||||||
func (this *TypeFloat) String () string {
|
func (this *TypeFloat) String () string {
|
||||||
@ -187,8 +187,8 @@ func (this *TypeFloat) Equals (ty Type) bool {
|
|||||||
// is chosen based on the machine word size (32 on 32 bit systems, 64 on 64 bit
|
// is chosen based on the machine word size (32 on 32 bit systems, 64 on 64 bit
|
||||||
// systems, etc)
|
// systems, etc)
|
||||||
type TypeWord struct {
|
type TypeWord struct {
|
||||||
Pos lexer.Position
|
Position errors.Position
|
||||||
Signed bool
|
Signed bool
|
||||||
}
|
}
|
||||||
func (*TypeWord) ty(){}
|
func (*TypeWord) ty(){}
|
||||||
func (this *TypeWord) String () string {
|
func (this *TypeWord) String () string {
|
||||||
|
Loading…
Reference in New Issue
Block a user