Skip to content
Browse files

Moved map and array into primary expressions, cleaned up inline funct…

…ion syntax
  • Loading branch information...
1 parent b8ae378 commit 9f318419284e8cb063c9469a7c6e691958165419 @nardo committed Nov 20, 2009
Showing with 18 additions and 20 deletions.
  1. +12 −13 parser/parser.bison
  2. +6 −7 test/test2/object_test.kt
View
25 parser/parser.bison
@@ -283,6 +283,15 @@ object_declaration
field($$, image_list, $5);
field($$, body, $7);
}
+ | IDENTIFIER parent_specifier image_list_specifier end_token compound_body optional_end_token
+ {
+ $$ = node(object);
+ field($$, is_public, false);
+ field($$, name, $1);
+ field($$, parent_decl, $2);
+ field($$, image_list, $3);
+ field($$, body, $5);
+ }
;
/*-----------------------------------------------------------------------------------------*/
@@ -731,6 +740,8 @@ primary_expression
{ $$ = $1; }
| '(' expression ')'
{ $$ = $2; }
+ | array_expression
+ | map_expression
;
fragmented_string
@@ -1084,18 +1095,6 @@ conditional_expression
assignment_expression
: conditional_expression
- | unary_expression '=' array_expression
- {
- $$ = node(assign_expr);
- field($$, left, $1);
- field($$, right, $3);
- }
- | unary_expression '=' map_expression
- {
- $$ = node(assign_expr);
- field($$, left, $1);
- field($$, right, $3);
- }
| unary_expression '=' assignment_expression
{
$$ = node(assign_expr);
@@ -1213,7 +1212,7 @@ map_pair
;
function_expression
- : "function" '(' optional_parameter_list ')' '{' expression '}'
+ : "function" '(' optional_parameter_list ')' '(' expression ')'
{
$$ = node(function_expr);
field($$, parameter_list, $3);
View
13 test/test2/object_test.kt
@@ -1,4 +1,4 @@
-object the_object
+the_object
var x = 10
var y = 20
function do_print()
@@ -8,15 +8,14 @@ function main()
the_object.do_print()
var value = 10
print(value == 10 ? "yes, it's 10" : "no, it's not!")
- var array
- array = [10, 20, 30]
+ var array = [10, 20, 30]
print("This should be 30: " @ array[2])
- array = { "foo" : "bar", "slash" : "dot", 100 : 5000 }
- print("This should be dot: " @ array["slash"])
+ var map = { "foo" : "bar", "slash" : "dot", 100 : 5000 }
+ print("This should be dot: " @ map["slash"])
function test_function(func)
- print("Sub function result = " @ func())
+ print("Sub function result = " @ func(20))
- test_function(function() { "sweetness!" } )
+ test_function(function(val) ( "sweetness! val = $val, value = $value" ) )

0 comments on commit 9f31841

Please sign in to comment.
Something went wrong with that request. Please try again.