;*/
function_definition
- : IDENTIFIER IDENTIFIER '(' optional_parameter_definitions ')' '{' optional_statements '}' {
+ : type IDENTIFIER '(' optional_parameter_definitions ')' '{' optional_statements '}' {
$$ = sltNodeMakeFunctionDefinition($1, $2, $4, $7);
}
;
;
parameter_definition
- : IDENTIFIER IDENTIFIER {
+ : type IDENTIFIER {
$$ = sltNodeMakeFunctionParameterDefinition($1, $2);
}
;
;*/
variable_definition
- : IDENTIFIER IDENTIFIER {
+ : type IDENTIFIER {
$$ = sltNodeMakeVariableDefinition($1, $2, NULL);
}
- | IDENTIFIER IDENTIFIER '=' expression {
+ | type IDENTIFIER '=' expression {
$$ = sltNodeMakeVariableDefinition($1, $2, $4);
}
;
+type
+ : IDENTIFIER {
+ $$ = $1;//sltNodeMakeTypeDefinition($1, 1);
+ }
+ | '[' type ':' INT ']' {
+ $$ = $2;//sltNodeMakeTypeDefinition($1, $2);
+ }
+ ;
+
optional_statements
: /* nothing */ {
$$ = NULL;
$$ = sltNodeMakeFunctionCall($1, $3);
}
| postfix_expression '.' IDENTIFIER {
- $$ = sltNodeMakeTypeAccess($1, $3);
+ $$ = sltNodeMakeMemberAccess($1, $3);
}
/*| postfix_expression postfix_unary_operator {
$$ = sltNodeMakeUnaryOperation($1, $2);
switch (type) {
case SLTNodeTypeModule:
case SLTNodeTypeFunctionDefinition:
- case SLTNodeTypeTypeDefinition:
+ case SLTNodeTypeUserDefinedTypeDefinition:
case SLTNodeTypeForIteration:
case SLTNodeTypeDoIteration:
case SLTNodeTypeWhileIteration:
return r;
}
- case SLTNodeTypeTypeAccess:
+ case SLTNodeTypeMemberAccess:
generator_assert_msg(false, "not implemented: %s", sltNodeToString(node));
return -1;
for (SLTNode *n = node->moduleStatementsAndDefinitions; n != NULL; n = n->sequenceNext) {
switch (n->sequenceNode->type) {
//case SLTNodeTypeVariableDefinition:
- case SLTNodeTypeTypeDefinition:
+ case SLTNodeTypeUserDefinedTypeDefinition:
case SLTNodeTypeFunctionDefinition:
// Do nothing...
break;
return node;
}
-SLTNode *sltNodeMakeTypeAccess(SLTNode *type, SLTNode *access) {
- SLTNode *node = node_make(SLTNodeTypeTypeAccess);
+SLTNode *sltNodeMakeMemberAccess(SLTNode *type, SLTNode *access) {
+ SLTNode *node = node_make(SLTNodeTypeMemberAccess);
node->typeAccessType = type;
node->typeAccessAccess = access;
return node;
return node;
}
-SLTNode *sltNodeMakeTypeDefinition(SLTNode *identifier, SLTNode *members) {
- SLTNode *node = node_make(SLTNodeTypeTypeDefinition);
+//extern SLTNode *sltNodeMakeTypeDefinition(SLTNode *identifier, SLTNode *dimension);
+
+SLTNode *sltNodeMakeUserDefinedTypeDefinition(SLTNode *identifier, SLTNode *members) {
+ SLTNode *node = node_make(SLTNodeTypeUserDefinedTypeDefinition);
node->typeDefinitionIdentifier = identifier;
node->typeDefinitionMembers = members;
return node;
}
-SLTNode *sltNodeMakeTypeMemberDefinition(SLTNode *type, SLTNode *identifier) {
- SLTNode *node = node_make(SLTNodeTypeTypeMemberDefinition);
+SLTNode *sltNodeMakeUserDefinedTypeMemberDefinition(SLTNode *type, SLTNode *identifier) {
+ SLTNode *node = node_make(SLTNodeTypeUserDefinedTypeMemberDefinition);
node->typeMemberDefinitionType = type;
node->typeMemberDefinitionIdentifier = identifier;
return node;
extern SLTNode *sltNodeMakeArgument(SLTNode *expression);
extern SLTNode *sltNodeMakeArrayAccess(SLTNode *array, SLTNode *access);
-extern SLTNode *sltNodeMakeTypeAccess(SLTNode *type, SLTNode *access);
+extern SLTNode *sltNodeMakeMemberAccess(SLTNode *type, SLTNode *access);
extern SLTNode *sltNodeMakeFunctionCall(SLTNode *function, SLTNode *arguments);
extern SLTNode *sltNodeMakeVariableDefinition(SLTNode *type, SLTNode *identifier, SLTNode *defaultExpression);
-extern SLTNode *sltNodeMakeTypeDefinition(SLTNode *identifier, SLTNode *members);
-extern SLTNode *sltNodeMakeTypeMemberDefinition(SLTNode *type, SLTNode *identifier);
+//extern SLTNode *sltNodeMakeTypeDefinition(SLTNode *identifier, SLTNode *dimension);
+
+extern SLTNode *sltNodeMakeUserDefinedTypeDefinition(SLTNode *identifier, SLTNode *members);
+extern SLTNode *sltNodeMakeUserDefinedTypeMemberDefinition(SLTNode *type, SLTNode *identifier);
extern SLTNode *sltNodeMakeFunctionDefinition(SLTNode *type, SLTNode *identifier, SLTNode *parameters, SLTNode *body);
extern SLTNode *sltNodeMakeFunctionParameterDefinition(SLTNode *type, SLTNode *identifier);
case SLTNodeTypeArrayAccess:
return "ArrayAccess";
- case SLTNodeTypeTypeAccess:
- return "TypeAccess";
+ case SLTNodeTypeMemberAccess:
+ return "MemberAccess";
case SLTNodeTypeFunctionCall:
return "FunctionCall";
case SLTNodeTypeVariableDefinition:
return "VariableDefinition";
- case SLTNodeTypeTypeDefinition:
- return "TypeDefinition";
+ case SLTNodeTypeUserDefinedTypeDefinition:
+ return "UserDefinedTypeDefinition";
- case SLTNodeTypeTypeMemberDefinition:
- return "TypeMemberDefinition";
+ case SLTNodeTypeUserDefinedTypeMemberDefinition:
+ return "UserDefinedTypeMemberDefinition";
case SLTNodeTypeFunctionDefinition:
return "FunctionDefinition";
SLTNodeTypeArgument,
SLTNodeTypeArrayAccess,
- SLTNodeTypeTypeAccess,
+ SLTNodeTypeMemberAccess,
SLTNodeTypeFunctionCall,
SLTNodeTypeVariableDefinition,
- SLTNodeTypeTypeDefinition,
- SLTNodeTypeTypeMemberDefinition,
+// SLTNodeTypeArrayTypeDefinition,
+
+ SLTNodeTypeUserDefinedTypeDefinition,
+ SLTNodeTypeUserDefinedTypeMemberDefinition,
SLTNodeTypeFunctionDefinition,
SLTNodeTypeFunctionParameterDefinition,
n->arrayAccessAccess = sltTreeMap(n->arrayAccessAccess, callback, postCallback, userParameter);
break;
- case SLTNodeTypeTypeAccess:
+ case SLTNodeTypeMemberAccess:
n->typeAccessType = sltTreeMap(n->typeAccessType, callback, postCallback, userParameter);
n->typeAccessAccess = sltTreeMap(n->typeAccessAccess, callback, postCallback, userParameter);
break;
n->variableDefinitionDefaultExpression = sltTreeMap(n->variableDefinitionDefaultExpression, callback, postCallback, userParameter);
break;
- case SLTNodeTypeTypeDefinition:
+ case SLTNodeTypeUserDefinedTypeDefinition:
n->typeDefinitionIdentifier = sltTreeMap(n->typeDefinitionIdentifier, callback, postCallback, userParameter);
n->typeDefinitionMembers = sltTreeMap(n->typeDefinitionMembers, callback, postCallback, userParameter);
break;
- case SLTNodeTypeTypeMemberDefinition:
+ case SLTNodeTypeUserDefinedTypeMemberDefinition:
n->typeMemberDefinitionType = sltTreeMap(n->typeMemberDefinitionType, callback, postCallback, userParameter);
n->typeMemberDefinitionIdentifier = sltTreeMap(n->typeMemberDefinitionIdentifier, callback, postCallback, userParameter);
break;