Documentation ¶
Index ¶
- Constants
- func IsDirectEntityReference(s RelationTypeStatement) bool
- type ActionStatement
- type EntityStatement
- type Expression
- type ExpressionStatement
- type ExpressionType
- type Identifier
- type InfixExpression
- type Node
- type Operator
- type RelationStatement
- type RelationTypeStatement
- type RelationalReferenceType
- type Schema
- func (sch *Schema) GetRelationReferenceIfExist(name string) ([]RelationTypeStatement, bool)
- func (sch *Schema) GetRelationalReferenceTypeIfExist(r string) (RelationalReferenceType, bool)
- func (sch *Schema) IsEntityReferenceExist(name string) bool
- func (sch *Schema) IsRelationReferenceExist(name string) bool
- func (sch *Schema) IsRelationalReferenceExist(name string) bool
- func (sch *Schema) SetActionReferences(r map[string]struct{})
- func (sch *Schema) SetEntityReferences(r map[string]struct{})
- func (sch *Schema) SetRelationReferences(r map[string][]RelationTypeStatement)
- func (sch *Schema) SetRelationalReferences(r map[string]RelationalReferenceType)
- func (sch *Schema) Validate() error
- type Statement
Constants ¶
const ( IDENTIFIER ExpressionType = "identifier" INFLIX ExpressionType = "inflix" AND Operator = "and" OR Operator = "or" ACTION RelationalReferenceType = "action" RELATION RelationalReferenceType = "relation" )
Variables ¶
This section is empty.
Functions ¶
func IsDirectEntityReference ¶ added in v0.3.1
func IsDirectEntityReference(s RelationTypeStatement) bool
IsDirectEntityReference returns true if the RelationTypeStatement is a direct entity reference.
Types ¶
type ActionStatement ¶
type ActionStatement struct { Action token.Token // token.ACTION Name token.Token // token.IDENT ExpressionStatement Statement }
ActionStatement represents an action statement, which consists of an action name and an optional expression statement. It implements the Statement interface.
func (*ActionStatement) String ¶
func (ls *ActionStatement) String() string
String returns a string representation of the action statement.
type EntityStatement ¶
type EntityStatement struct { Entity token.Token // token.ENTITY Name token.Token // token.IDENT RelationStatements []Statement // Statements that define relationships between entities ActionStatements []Statement // Statements that define actions performed on the entity }
EntityStatement represents a statement that refers to an entity.
func (*EntityStatement) String ¶
func (ls *EntityStatement) String() string
String returns a string representation of the EntityStatement.
type Expression ¶
type Expression interface { Node IsInfix() bool GetType() ExpressionType // contains filtered or unexported methods }
Expression defines an interface for an expression node.
type ExpressionStatement ¶
type ExpressionStatement struct {
Expression Expression
}
ExpressionStatement struct represents an expression statement
func (*ExpressionStatement) String ¶
func (es *ExpressionStatement) String() string
String function returns a string representation of the ExpressionStatement
type Identifier ¶
type Identifier struct { Prefix token.Token // Prefix is a token that negates the identifier Idents []token.Token // Idents is a slice of tokens that make up the identifier }
Identifier represents an expression that identifies an entity, action or relation
func (*Identifier) GetType ¶
func (ls *Identifier) GetType() ExpressionType
GetType returns the type of the expression which is Identifier
func (*Identifier) IsInfix ¶
func (ls *Identifier) IsInfix() bool
IsInfix returns false since an identifier is not an infix expression
func (*Identifier) IsPrefix ¶ added in v0.3.1
func (ls *Identifier) IsPrefix() bool
IsPrefix returns true if the identifier has a negating prefix
func (*Identifier) String ¶
func (ls *Identifier) String() string
String returns a string representation of the identifier expression
type InfixExpression ¶
type InfixExpression struct { Op token.Token // The operator token, e.g. and, or. Left Expression // The left-hand side sub-expression. Operator Operator // The operator as a string. Right Expression // The right-hand side sub-expression. }
InfixExpression represents an expression with an operator between two sub-expressions.
func (*InfixExpression) GetType ¶
func (ie *InfixExpression) GetType() ExpressionType
GetType returns the type of the expression, which is infix.
func (*InfixExpression) IsInfix ¶
func (ie *InfixExpression) IsInfix() bool
IsInfix returns true because it's an infix expression.
func (*InfixExpression) String ¶
func (ie *InfixExpression) String() string
String returns the string representation of the infix expression.
type RelationStatement ¶
type RelationStatement struct { Relation token.Token // token.RELATION Name token.Token // token.IDENT RelationTypes []RelationTypeStatement // Statements that define the types of the relationship }
RelationStatement represents a statement that defines a relationship between two entities.
func (*RelationStatement) String ¶
func (ls *RelationStatement) String() string
String returns a string representation of the RelationStatement.
type RelationTypeStatement ¶
type RelationTypeStatement struct { Sign token.Token // token.SIGN Type token.Token // token.IDENT Relation token.Token // token.IDENT }
RelationTypeStatement represents a statement that defines the type of a relationship.
func (*RelationTypeStatement) String ¶
func (ls *RelationTypeStatement) String() string
String returns a string representation of the RelationTypeStatement.
type RelationalReferenceType ¶
type RelationalReferenceType string
RelationalReferenceType defines the type of relational reference.
type Schema ¶
type Schema struct { // The list of statements in the schema Statements []Statement // contains filtered or unexported fields }
Schema represents the parsed schema, which contains all the statements and extracted entity and relational references used by the schema. It is used as an intermediate representation before generating the corresponding metadata.
func (*Schema) GetRelationReferenceIfExist ¶
func (sch *Schema) GetRelationReferenceIfExist(name string) ([]RelationTypeStatement, bool)
GetRelationReferenceIfExist returns the relation reference if it exists in the schema
func (*Schema) GetRelationalReferenceTypeIfExist ¶
func (sch *Schema) GetRelationalReferenceTypeIfExist(r string) (RelationalReferenceType, bool)
GetRelationalReferenceTypeIfExist returns the relational reference type if it exists
func (*Schema) IsEntityReferenceExist ¶
IsEntityReferenceExist checks if the entity reference exists in the schema
func (*Schema) IsRelationReferenceExist ¶
IsRelationReferenceExist checks if the relation reference exists in the schema
func (*Schema) IsRelationalReferenceExist ¶ added in v0.3.1
IsRelationalReferenceExist checks if the relational reference exists in the schema
func (*Schema) SetActionReferences ¶
SetActionReferences sets the action references in the schema
func (*Schema) SetEntityReferences ¶
SetEntityReferences sets the entity references in the schema
func (*Schema) SetRelationReferences ¶
func (sch *Schema) SetRelationReferences(r map[string][]RelationTypeStatement)
SetRelationReferences sets the relation references in the schema
func (*Schema) SetRelationalReferences ¶
func (sch *Schema) SetRelationalReferences(r map[string]RelationalReferenceType)
SetRelationalReferences sets the relational references in the schema