@@ -387,12 +387,12 @@ func defaultVarValue(valueType ValueType, ctx context) (Expression, error) {
387387 case TypeKindString :
388388 return StringLiteral {}, nil
389389 case TypeKindStruct :
390- structDeclaration , exists := elementaryDataType .(StructDeclaration )
390+ structDefinition , exists := elementaryDataType .(StructDefinition )
391391
392392 if exists {
393393 structValues := []StructValue {}
394394
395- for _ , field := range structDeclaration .Fields () {
395+ for _ , field := range structDefinition .Fields () {
396396 defaultValue , err := defaultVarValue (field .ValueType (), ctx )
397397
398398 if err != nil {
@@ -406,7 +406,7 @@ func defaultVarValue(valueType ValueType, ctx context) (Expression, error) {
406406 value : defaultValue ,
407407 })
408408 }
409- return NewStructDefinition (valueType .Type (), structValues ... ), nil
409+ return NewStructInitialization (valueType .Type (), structValues ... ), nil
410410 }
411411 }
412412 } else {
@@ -1222,21 +1222,21 @@ func (p *Parser) evaluateValueType(ctx context) (ValueType, error) {
12221222 return evaluatedType , nil
12231223}
12241224
1225- func (p * Parser ) evaluateStructDeclaration (name string , ctx context ) (StructDeclaration , error ) {
1225+ func (p * Parser ) evaluateStructDefinition (name string , ctx context ) (StructDefinition , error ) {
12261226 structToken := p .eat ()
12271227
12281228 if structToken .Type () != lexer .STRUCT {
1229- return StructDeclaration {}, p .expectedKeywordError ("struct" , structToken )
1229+ return StructDefinition {}, p .expectedKeywordError ("struct" , structToken )
12301230 }
12311231 nextToken := p .eat ()
12321232
12331233 if nextToken .Type () != lexer .OPENING_CURLY_BRACKET {
1234- return StructDeclaration {}, p .expectedError (`"{"` , nextToken )
1234+ return StructDefinition {}, p .expectedError (`"{"` , nextToken )
12351235 }
12361236 nextToken = p .eat ()
12371237
12381238 if nextToken .Type () != lexer .NEWLINE {
1239- return StructDeclaration {}, p .expectedNewlineError (nextToken )
1239+ return StructDefinition {}, p .expectedNewlineError (nextToken )
12401240 }
12411241 fields := []StructField {}
12421242
@@ -1245,18 +1245,18 @@ func (p *Parser) evaluateStructDeclaration(name string, ctx context) (StructDecl
12451245 nameTokens , err := p .evaluateNames ()
12461246
12471247 if err != nil {
1248- return StructDeclaration {}, err
1248+ return StructDefinition {}, err
12491249 }
12501250 valueTypeToken := p .peek ()
12511251 valueType , err := p .evaluateValueType (ctx )
12521252
12531253 if err != nil {
1254- return StructDeclaration {}, err
1254+ return StructDefinition {}, err
12551255 }
12561256
12571257 // Don't allow nested structs for now.
12581258 if valueType .Type ().Kind () == TypeKindStruct {
1259- return StructDeclaration {}, p .atError ("nested structs are not allowed" , valueTypeToken )
1259+ return StructDefinition {}, p .atError ("nested structs are not allowed" , valueTypeToken )
12601260 }
12611261
12621262 for _ , nameToken := range nameTokens {
@@ -1268,7 +1268,7 @@ func (p *Parser) evaluateStructDeclaration(name string, ctx context) (StructDecl
12681268 nextToken = p .eat ()
12691269
12701270 if nextToken .Type () != lexer .NEWLINE {
1271- return StructDeclaration {}, p .expectedNewlineError (nextToken )
1271+ return StructDefinition {}, p .expectedNewlineError (nextToken )
12721272 }
12731273 nextToken = p .peek ()
12741274
@@ -1277,7 +1277,7 @@ func (p *Parser) evaluateStructDeclaration(name string, ctx context) (StructDecl
12771277 break
12781278 }
12791279 }
1280- return NewStructDeclaration (name , fields ), nil
1280+ return NewStructDefinition (name , fields ), nil
12811281}
12821282
12831283func (p * Parser ) evaluateTypeDeclaration (ctx context ) (Statement , error ) {
@@ -1310,12 +1310,12 @@ func (p *Parser) evaluateTypeDeclaration(ctx context) (Statement, error) {
13101310 if isAlias {
13111311 return nil , p .atError ("struct alias is not supported" , assignToken )
13121312 }
1313- structDeclaration , err := p .evaluateStructDeclaration (name , ctx )
1313+ structDefinition , err := p .evaluateStructDefinition (name , ctx )
13141314
13151315 if err != nil {
13161316 return nil , err
13171317 }
1318- valueType = NewValueType (structDeclaration , false )
1318+ valueType = NewValueType (structDefinition , false )
13191319 } else {
13201320 valueType , err = p .evaluateValueType (ctx )
13211321
@@ -2584,11 +2584,11 @@ func (p *Parser) evaluateStructEvaluation(importAlias string, ctx context) (Expr
25842584 if typeDeclarationKind != TypeKindStruct {
25852585 return nil , p .expectedError (fmt .Sprintf ("%s but got %s" , TypeKindStruct , typeDeclarationKind ), identifierToken )
25862586 }
2587- structDeclaration := typeDeclaration .(StructDeclaration )
2587+ structDefinition := typeDeclaration .(StructDefinition )
25882588
25892589 // Check field.
25902590 fieldName := fieldToken .Value ()
2591- foundField , err := structDeclaration .FindField (fieldName )
2591+ foundField , err := structDefinition .FindField (fieldName )
25922592
25932593 if err != nil {
25942594 return nil , p .atError (err .Error (), fieldToken )
@@ -3322,8 +3322,8 @@ func (p *Parser) evaluateStructInitialization(ctx context) (Expression, error) {
33223322 if err != nil {
33233323 return nil , err
33243324 }
3325- structInitialization := intialization .(StructDefinition )
3326- structDeclaration , valid := structValueType .Type ().(StructDeclaration )
3325+ structInitialization := intialization .(StructInitialization )
3326+ structDefinition , valid := structValueType .Type ().(StructDefinition )
33273327
33283328 if ! valid || structValueType .IsSlice () {
33293329 return nil , p .expectedError (fmt .Sprintf ("struct type but got %s" , structValueType .String ()), nextToken )
@@ -3334,7 +3334,7 @@ func (p *Parser) evaluateStructInitialization(ctx context) (Expression, error) {
33343334 if len (fieldName ) == 0 {
33353335 return p .expectedError ("field name" , initValue .nameToken )
33363336 }
3337- structField , err := structDeclaration .FindField (fieldName )
3337+ structField , err := structDefinition .FindField (fieldName )
33383338
33393339 if err != nil {
33403340 return err
@@ -3558,7 +3558,7 @@ func (p *Parser) evaluateStructAssignment(ctx context) (Statement, error) {
35583558 } else if namedValueBaseType .Kind () != TypeKindStruct {
35593559 return nil , p .expectedError (fmt .Sprintf ("struct but variable is of type %s" , namedValueBaseType .Kind ()), nameToken )
35603560 }
3561- structDeclaration := namedValueBaseType .(StructDeclaration )
3561+ structDefinition := namedValueBaseType .(StructDefinition )
35623562 nextToken := p .eat ()
35633563
35643564 if nextToken .Type () != lexer .DOT {
@@ -3569,7 +3569,7 @@ func (p *Parser) evaluateStructAssignment(ctx context) (Statement, error) {
35693569 if nextToken .Type () != lexer .IDENTIFIER {
35703570 return nil , p .expectedError (`struct field` , nextToken )
35713571 }
3572- structField , err := structDeclaration .FindField (nextToken .Value ())
3572+ structField , err := structDefinition .FindField (nextToken .Value ())
35733573
35743574 if err != nil {
35753575 return nil , p .atError (err .Error (), nextToken )
0 commit comments