fancy 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -14
- data/Rakefile +16 -4
- data/bin/fancy +3 -0
- data/bin/fspec +20 -0
- data/bin/fyi +27 -11
- data/bin/ifancy +1 -1
- data/boot/fancy_ext.rb +1 -0
- data/boot/fancy_ext/block_env.rb +1 -9
- data/boot/fancy_ext/delegator.rb +64 -0
- data/boot/fancy_ext/object.rb +4 -0
- data/boot/fancy_ext/thread.rb +4 -0
- data/boot/load.rb +5 -1
- data/boot/rbx-compiler/compiler/ast.rb +0 -1
- data/boot/rbx-compiler/compiler/ast/class_def.rb +2 -0
- data/boot/rbx-compiler/compiler/ast/method_def.rb +2 -0
- data/boot/rbx-compiler/compiler/ast/node.rb +10 -0
- data/boot/rbx-compiler/compiler/ast/ruby_args.rb +12 -0
- data/boot/rbx-compiler/compiler/ast/singleton_method_def.rb +2 -0
- data/boot/rbx-compiler/parser/fancy_parser.bundle +0 -0
- data/boot/rbx-compiler/parser/lexer.lex +5 -11
- data/boot/rbx-compiler/parser/parser.rb +16 -5
- data/boot/rbx-compiler/parser/parser.y +39 -24
- data/doc/api/fancy.css +1 -1
- data/doc/api/fancy.jsonp +1 -1
- data/doc/api/fdoc.js +22 -4
- data/doc/api/index.html +5 -6
- data/doc/api/jquery-ui.min.js +401 -0
- data/doc/api/jquery.tools.min.js +192 -0
- data/doc/api/themeswitchertool.js +250 -0
- data/doc/features.md +17 -0
- data/examples/actor_bunnies.fy +32 -0
- data/examples/actors.fy +26 -0
- data/examples/actors_primitive.fy +27 -0
- data/examples/actors_ring.fy +37 -0
- data/examples/armstrong_numbers.fy +1 -1
- data/examples/array.fy +7 -9
- data/examples/async_send.fy +1 -2
- data/examples/blocks.fy +4 -4
- data/examples/call_with_receiver.fy +1 -1
- data/examples/class.fy +1 -1
- data/examples/default_args.fy +4 -1
- data/examples/define_methods.fy +2 -2
- data/examples/echo.fy +1 -1
- data/examples/factorial.fy +1 -1
- data/examples/future_composition.fy +2 -2
- data/examples/futures.fy +0 -5
- data/examples/game_of_life.fy +1 -1
- data/examples/person.fy +1 -1
- data/lib/argv.fy +7 -2
- data/lib/array.fy +109 -42
- data/lib/block.fy +39 -14
- data/lib/boot.fy +2 -0
- data/lib/class.fy +2 -0
- data/lib/compiler/ast.fy +2 -1
- data/lib/compiler/ast/assign.fy +2 -3
- data/lib/compiler/ast/async_send.fy +1 -15
- data/lib/compiler/ast/class_def.fy +2 -1
- data/lib/compiler/ast/expression_list.fy +4 -5
- data/lib/compiler/ast/future_send.fy +1 -10
- data/lib/compiler/ast/goto.fy +46 -0
- data/lib/compiler/ast/identifier.fy +9 -7
- data/lib/compiler/ast/literals.fy +8 -1
- data/lib/compiler/ast/match.fy +14 -4
- data/lib/compiler/ast/message_send.fy +34 -6
- data/lib/compiler/ast/method_def.fy +6 -6
- data/lib/compiler/ast/node.fy +3 -3
- data/lib/compiler/ast/range.fy +1 -0
- data/lib/compiler/ast/script.fy +0 -2
- data/lib/compiler/ast/singleton_method_def.fy +2 -4
- data/lib/compiler/ast/string_interpolation.fy +17 -0
- data/lib/compiler/ast/super.fy +5 -4
- data/lib/compiler/ast/try_catch.fy +8 -6
- data/lib/compiler/ast/tuple_literal.fy +3 -2
- data/lib/compiler/command.fy +0 -1
- data/lib/compiler/compiler.fy +1 -5
- data/lib/compiler/stages.fy +6 -14
- data/lib/documentation.fy +57 -46
- data/lib/enumerable.fy +257 -23
- data/lib/enumerator.fy +122 -15
- data/lib/false_class.fy +10 -1
- data/lib/fancy_spec.fy +263 -61
- data/lib/fdoc.fy +11 -25
- data/lib/fiber.fy +11 -0
- data/lib/file.fy +8 -11
- data/lib/future.fy +84 -5
- data/lib/hash.fy +65 -14
- data/lib/integer.fy +35 -0
- data/lib/iteration.fy +54 -29
- data/lib/message.fy +6 -0
- data/lib/method.fy +0 -16
- data/lib/nil_class.fy +58 -8
- data/lib/number.fy +49 -22
- data/lib/object.fy +371 -65
- data/lib/package.fy +24 -1
- data/lib/package/installer.fy +5 -9
- data/lib/package/specification.fy +2 -2
- data/lib/parser/ext/lexer.lex +15 -11
- data/lib/parser/ext/parser.y +70 -23
- data/lib/parser/methods.fy +33 -14
- data/lib/proxy.fy +33 -3
- data/lib/range.fy +28 -0
- data/lib/rbx.fy +3 -1
- data/lib/rbx/actor.fy +53 -0
- data/lib/rbx/alpha.fy +31 -0
- data/lib/rbx/array.fy +21 -12
- data/lib/rbx/bignum.fy +6 -2
- data/lib/rbx/block.fy +23 -26
- data/lib/rbx/class.fy +54 -2
- data/lib/rbx/code_loader.fy +8 -4
- data/lib/rbx/date.fy +9 -0
- data/lib/rbx/directory.fy +18 -0
- data/lib/rbx/environment_variables.fy +1 -0
- data/lib/rbx/exception.fy +9 -2
- data/lib/rbx/fiber.fy +22 -4
- data/lib/rbx/file.fy +5 -5
- data/lib/rbx/fixnum.fy +5 -0
- data/lib/rbx/float.fy +11 -3
- data/lib/rbx/hash.fy +31 -16
- data/lib/rbx/integer.fy +1 -0
- data/lib/rbx/io.fy +17 -7
- data/lib/rbx/match_data.fy +15 -4
- data/lib/rbx/method.fy +40 -7
- data/lib/rbx/name_error.fy +4 -0
- data/lib/rbx/object.fy +92 -24
- data/lib/rbx/range.fy +20 -6
- data/lib/rbx/regexp.fy +11 -3
- data/lib/rbx/string.fy +51 -1
- data/lib/rbx/stringio.fy +17 -0
- data/lib/rbx/symbol.fy +15 -1
- data/lib/rbx/system.fy +20 -2
- data/lib/rbx/tcp_server.fy +4 -1
- data/lib/rbx/tcp_socket.fy +11 -0
- data/lib/rbx/time.fy +6 -0
- data/lib/rbx/tuple.fy +14 -5
- data/lib/set.fy +144 -29
- data/lib/stack.fy +42 -11
- data/lib/string.fy +118 -8
- data/lib/struct.fy +13 -3
- data/lib/symbol.fy +21 -2
- data/lib/thread_pool.fy +2 -1
- data/lib/true_class.fy +45 -7
- data/lib/tuple.fy +27 -9
- data/lib/version.fy +2 -2
- data/ruby_lib/fancy +43 -0
- data/ruby_lib/fdoc +23 -0
- data/ruby_lib/fspec +3 -0
- data/ruby_lib/fyi +3 -0
- data/ruby_lib/ifancy +3 -0
- data/tests/argv.fy +5 -9
- data/tests/array.fy +323 -196
- data/tests/assignment.fy +29 -29
- data/tests/block.fy +72 -59
- data/tests/class.fy +227 -138
- data/tests/control_flow.fy +83 -51
- data/tests/documentation.fy +8 -8
- data/tests/enumerable.fy +8 -0
- data/tests/enumerator.fy +47 -29
- data/tests/exception.fy +49 -32
- data/tests/file.fy +28 -28
- data/tests/fixnum.fy +170 -0
- data/tests/future.fy +24 -7
- data/tests/hash.fy +55 -38
- data/tests/method.fy +50 -43
- data/tests/nil_class.fy +37 -37
- data/tests/object.fy +152 -70
- data/tests/pattern_matching.fy +67 -31
- data/tests/range.fy +6 -6
- data/tests/set.fy +101 -4
- data/tests/stack.fy +14 -5
- data/tests/string.fy +115 -61
- data/tests/stringio.fy +18 -0
- data/tests/struct.fy +27 -0
- data/tests/symbol.fy +19 -6
- data/tests/true_class.fy +34 -34
- data/tests/tuple.fy +30 -12
- metadata +103 -81
- data/boot/rbx-compiler/compiler/ast/require.rb +0 -20
- data/examples/actor.fy +0 -37
- data/examples/curl_async.fy +0 -37
- data/lib/compiler/ast/require.fy +0 -15
- data/tests/number.fy +0 -135
- data/tests/parsing/sexp.fy +0 -50
data/lib/package.fy
CHANGED
@@ -25,9 +25,14 @@ class Fancy Package {
|
|
25
25
|
"""
|
26
26
|
|
27
27
|
ENV_PACKAGE_DIR_VAR = "FANCY_PACKAGE_DIR"
|
28
|
+
DEFAULT_FANCY_ROOT = ENV["HOME"] ++ "/.fancy"
|
29
|
+
DEFAULT_PACKAGES_PATH = DEFAULT_FANCY_ROOT ++ "/packages"
|
30
|
+
DEFAULT_PACKAGES_LIB_PATH = DEFAULT_PACKAGES_PATH ++ "/lib"
|
28
31
|
|
29
32
|
def self install: package_name {
|
30
33
|
"""
|
34
|
+
@package_name Name of package to install.
|
35
|
+
|
31
36
|
Installs a package with a given name.
|
32
37
|
Expects package_name to be a string in the form of:
|
33
38
|
user/repo
|
@@ -38,22 +43,40 @@ class Fancy Package {
|
|
38
43
|
}
|
39
44
|
|
40
45
|
def self uninstall: package_name {
|
46
|
+
"""
|
47
|
+
@package_name Name of package to uninstall.
|
48
|
+
|
49
|
+
Uninstalls a package with a given name (if installed).
|
50
|
+
"""
|
51
|
+
|
41
52
|
Uninstaller new: package_name . run
|
42
53
|
}
|
43
54
|
|
44
55
|
def self list_packages {
|
56
|
+
"""
|
57
|
+
Lists (prints) all installed packages on this system.
|
58
|
+
"""
|
59
|
+
|
45
60
|
Fancy Package List new: package_list_file . println
|
46
61
|
}
|
47
62
|
|
48
63
|
def self root_dir {
|
64
|
+
"""
|
65
|
+
@return Fancy Package root install dir.
|
66
|
+
"""
|
67
|
+
|
49
68
|
if: (ENV[ENV_PACKAGE_DIR_VAR]) then: |path| {
|
50
69
|
return path
|
51
70
|
} else: {
|
52
|
-
return
|
71
|
+
return DEFAULT_PACKAGES_PATH
|
53
72
|
}
|
54
73
|
}
|
55
74
|
|
56
75
|
def self package_list_file {
|
76
|
+
"""
|
77
|
+
@return Path to installed_packages.txt @File@ on system.
|
78
|
+
"""
|
79
|
+
|
57
80
|
"#{self root_dir}/installed_packages.txt"
|
58
81
|
}
|
59
82
|
|
data/lib/package/installer.fy
CHANGED
@@ -13,10 +13,6 @@ class Fancy Package {
|
|
13
13
|
|
14
14
|
"""
|
15
15
|
|
16
|
-
DEFAULT_FANCY_ROOT = ENV["HOME"] ++ "/.fancy"
|
17
|
-
DEFAULT_PACKAGES_PATH = DEFAULT_FANCY_ROOT ++ "/packages"
|
18
|
-
DEFAULT_PACKAGES_LIB_PATH = DEFAULT_PACKAGES_PATH ++ "/lib"
|
19
|
-
|
20
16
|
def initialize: @package_name version: @version ("latest") install_path: @install_path (ENV["FANCY_PACKAGE_DIR"]) {
|
21
17
|
"""
|
22
18
|
Creates a new @Package Installer@ for a given package name, an
|
@@ -37,11 +33,11 @@ class Fancy Package {
|
|
37
33
|
}
|
38
34
|
|
39
35
|
@install_path if_nil: {
|
40
|
-
@install_path = DEFAULT_PACKAGES_PATH
|
41
|
-
Directory create!: DEFAULT_FANCY_ROOT
|
42
|
-
Directory create!: DEFAULT_PACKAGES_PATH
|
43
|
-
Directory create!: DEFAULT_PACKAGES_LIB_PATH
|
44
|
-
Directory create!: $ DEFAULT_PACKAGES_PATH ++ "/downloads"
|
36
|
+
@install_path = Fancy Package DEFAULT_PACKAGES_PATH
|
37
|
+
Directory create!: $ Fancy Package DEFAULT_FANCY_ROOT
|
38
|
+
Directory create!: $ Fancy Package DEFAULT_PACKAGES_PATH
|
39
|
+
Directory create!: $ Fancy Package DEFAULT_PACKAGES_LIB_PATH
|
40
|
+
Directory create!: $ Fancy Package DEFAULT_PACKAGES_PATH ++ "/downloads"
|
45
41
|
}
|
46
42
|
|
47
43
|
@download_path = @install_path ++ "/downloads"
|
@@ -15,7 +15,7 @@ class Fancy Package {
|
|
15
15
|
|
16
16
|
block call_with_receiver: self
|
17
17
|
|
18
|
-
@@specs
|
18
|
+
@@specs[@package_name]: self
|
19
19
|
}
|
20
20
|
|
21
21
|
def dependencies: dependencies {
|
@@ -52,7 +52,7 @@ class Fancy Package {
|
|
52
52
|
"name=#{@package_name} version=#{@version} url=https://github.com/#{@gh_user}/#{@package_name}"
|
53
53
|
}
|
54
54
|
|
55
|
-
def self []
|
55
|
+
def self [package_name] {
|
56
56
|
@@specs[package_name]
|
57
57
|
}
|
58
58
|
|
data/lib/parser/ext/lexer.lex
CHANGED
@@ -16,7 +16,7 @@ lower [a-z]
|
|
16
16
|
letter [A-Za-z]
|
17
17
|
special [-+?!=*/^><%&~]
|
18
18
|
special_under ({special}|"_")
|
19
|
-
operator ({special}+|"||"{special_under}*)
|
19
|
+
operator ({special}+|" | "|"||"{special_under}*)
|
20
20
|
int_lit [-+]?{digit}({digit}|_{digit})*
|
21
21
|
double_lit {int_lit}\.{digit}+
|
22
22
|
hex_lit 0[xX]{hexdigit}+
|
@@ -42,23 +42,22 @@ thin_arrow "->"
|
|
42
42
|
delimiter [ \n\r\t\(\)]
|
43
43
|
return_local "return_local"
|
44
44
|
return "return"
|
45
|
-
require "require:"
|
46
45
|
try "try"
|
47
46
|
catch "catch"
|
48
47
|
finally "finally"
|
49
48
|
retry "retry"
|
50
49
|
super "super"
|
51
|
-
private "private"
|
52
|
-
protected "protected"
|
53
50
|
self "self"
|
54
51
|
match "match"
|
55
52
|
case "case"
|
56
53
|
identifier @?@?({lower}|[_&*])({letter}|{digit}|{special_under})*
|
54
|
+
label @{identifier}@
|
55
|
+
goto_ "goto"
|
57
56
|
selector ({letter}|[_&*])({letter}|{digit}|{special_under})*":"
|
58
57
|
constant {capital}({letter}|{digit}|{special_under})*
|
59
58
|
nested_constant ({constant}::)+{constant}
|
60
|
-
symbol_lit \'({identifier}|{operator}|{constant}|:|"[]")+
|
61
|
-
ruby_send_open {identifier}{lparen}
|
59
|
+
symbol_lit \'({identifier}|{operator}|{constant}|:|"[]"|"|")+
|
60
|
+
ruby_send_open ({constant}|{identifier}){lparen}
|
62
61
|
ruby_oper_open {operator}{lparen}
|
63
62
|
regexp_lit "/".*"/"
|
64
63
|
comma ,
|
@@ -118,8 +117,8 @@ escaped_newline "\\".*\n
|
|
118
117
|
{rcurly} { return RCURLY; }
|
119
118
|
{lbracket} { return LBRACKET; }
|
120
119
|
{rbracket} { return RBRACKET; }
|
121
|
-
{lhash} { return
|
122
|
-
{rhash} { return
|
120
|
+
{lhash} { return LEFTHASH; }
|
121
|
+
{rhash} { return RIGHTHASH; }
|
123
122
|
{stab} { return STAB; }
|
124
123
|
{arrow} { return ARROW; }
|
125
124
|
{thin_arrow} { return THIN_ARROW; }
|
@@ -130,14 +129,11 @@ escaped_newline "\\".*\n
|
|
130
129
|
}
|
131
130
|
{return_local} { return RETURN_LOCAL; }
|
132
131
|
{return} { return RETURN; }
|
133
|
-
{require} { return REQUIRE; }
|
134
132
|
{try} { return TRY; }
|
135
133
|
{catch} { return CATCH; }
|
136
134
|
{finally} { return FINALLY; }
|
137
135
|
{retry} { return RETRY; }
|
138
136
|
{super} { return SUPER; }
|
139
|
-
{private} { return PRIVATE; }
|
140
|
-
{protected} { return PROTECTED; }
|
141
137
|
{self} {
|
142
138
|
yylval.object = rb_str_new2(yytext);
|
143
139
|
return IDENTIFIER;
|
@@ -148,6 +144,14 @@ escaped_newline "\\".*\n
|
|
148
144
|
{case} {
|
149
145
|
return CASE;
|
150
146
|
}
|
147
|
+
{goto_} {
|
148
|
+
yylval.object = rb_str_new2(yytext);
|
149
|
+
return GOTO;
|
150
|
+
}
|
151
|
+
{label} {
|
152
|
+
yylval.object = rb_str_new2(yytext);
|
153
|
+
return LABEL;
|
154
|
+
}
|
151
155
|
{identifier} {
|
152
156
|
yylval.object = rb_str_new2(yytext);
|
153
157
|
return IDENTIFIER;
|
data/lib/parser/ext/parser.y
CHANGED
@@ -31,8 +31,8 @@ extern char *yytext;
|
|
31
31
|
%token RCURLY
|
32
32
|
%token LBRACKET
|
33
33
|
%token RBRACKET
|
34
|
-
%token
|
35
|
-
%token
|
34
|
+
%token LEFTHASH
|
35
|
+
%token RIGHTHASH
|
36
36
|
%token STAB
|
37
37
|
%token ARROW
|
38
38
|
%token THIN_ARROW
|
@@ -42,14 +42,11 @@ extern char *yytext;
|
|
42
42
|
%token COLON
|
43
43
|
%token RETURN_LOCAL
|
44
44
|
%token RETURN
|
45
|
-
%token REQUIRE
|
46
45
|
%token TRY
|
47
46
|
%token CATCH
|
48
47
|
%token FINALLY
|
49
48
|
%token RETRY
|
50
49
|
%token SUPER
|
51
|
-
%token PRIVATE
|
52
|
-
%token PROTECTED
|
53
50
|
%token CLASS
|
54
51
|
%token DEF
|
55
52
|
%token DOT
|
@@ -58,6 +55,8 @@ extern char *yytext;
|
|
58
55
|
%token MATCH
|
59
56
|
%token CASE
|
60
57
|
%token IDENTIFIER
|
58
|
+
%token GOTO
|
59
|
+
%token LABEL
|
61
60
|
%token SELECTOR
|
62
61
|
%token RUBY_SEND_OPEN
|
63
62
|
%token RUBY_OPER_OPEN
|
@@ -91,6 +90,9 @@ extern char *yytext;
|
|
91
90
|
|
92
91
|
|
93
92
|
%type <object> identifier
|
93
|
+
%type <object> goto_statement
|
94
|
+
%type <object> label_literal
|
95
|
+
%type <object> label_statement
|
94
96
|
%type <object> any_identifier
|
95
97
|
%type <object> constant
|
96
98
|
%type <object> literal_value
|
@@ -118,7 +120,6 @@ extern char *yytext;
|
|
118
120
|
%type <object> identifier_list
|
119
121
|
%type <object> return_local_statement
|
120
122
|
%type <object> return_statement
|
121
|
-
%type <object> require_statement
|
122
123
|
|
123
124
|
%type <object> def
|
124
125
|
|
@@ -209,6 +210,7 @@ expression_block: LCURLY space expression_list space RCURLY {
|
|
209
210
|
}
|
210
211
|
;
|
211
212
|
|
213
|
+
|
212
214
|
partial_expression_block: AT_LCURLY space expression_list space RCURLY {
|
213
215
|
$$ = $3;
|
214
216
|
}
|
@@ -217,7 +219,23 @@ partial_expression_block: AT_LCURLY space expression_list space RCURLY {
|
|
217
219
|
statement: assignment
|
218
220
|
| return_local_statement
|
219
221
|
| return_statement
|
220
|
-
|
|
222
|
+
| label_statement
|
223
|
+
| goto_statement
|
224
|
+
;
|
225
|
+
|
226
|
+
label_literal: LABEL {
|
227
|
+
$$ = fy_terminal_node(self, "ast:string_value:");
|
228
|
+
}
|
229
|
+
;
|
230
|
+
|
231
|
+
label_statement: label_literal {
|
232
|
+
$$ = rb_funcall(self, rb_intern("ast:label:"), 2, INT2NUM(yylineno), $1);
|
233
|
+
}
|
234
|
+
;
|
235
|
+
|
236
|
+
goto_statement: GOTO label_literal {
|
237
|
+
$$ = rb_funcall(self, rb_intern("ast:goto:"), 2, INT2NUM(yylineno), $2);
|
238
|
+
}
|
221
239
|
;
|
222
240
|
|
223
241
|
primary: any_identifier
|
@@ -265,7 +283,8 @@ constant: CONSTANT {
|
|
265
283
|
|
266
284
|
selector: SELECTOR {
|
267
285
|
$$ = fy_terminal_node(self, "ast:identifier:");
|
268
|
-
}
|
286
|
+
}
|
287
|
+
;
|
269
288
|
|
270
289
|
identifier: IDENTIFIER {
|
271
290
|
$$ = fy_terminal_node(self, "ast:identifier:");
|
@@ -306,12 +325,6 @@ return_statement: RETURN exp {
|
|
306
325
|
}
|
307
326
|
;
|
308
327
|
|
309
|
-
require_statement: REQUIRE string_literal {
|
310
|
-
$$ = rb_funcall(self, rb_intern("ast:require_:"), 2, INT2NUM(yylineno), $2);
|
311
|
-
}
|
312
|
-
| REQUIRE any_identifier {
|
313
|
-
$$ = rb_funcall(self, rb_intern("ast:require_:"), 2, INT2NUM(yylineno), $2);
|
314
|
-
}
|
315
328
|
;
|
316
329
|
|
317
330
|
class_def: class_no_super
|
@@ -326,19 +339,23 @@ const_identifier: constant {
|
|
326
339
|
}
|
327
340
|
;
|
328
341
|
|
329
|
-
def: DEF
|
330
|
-
| DEF PROTECTED { $$ = rb_intern("protected"); }
|
331
|
-
| DEF { $$ = rb_intern("public"); }
|
342
|
+
def: DEF { $$ = rb_intern("public"); }
|
332
343
|
;
|
333
344
|
|
334
345
|
class_no_super: CLASS const_identifier expression_block {
|
335
346
|
$$ = rb_funcall(self, rb_intern("ast:class:parent:body:"), 4, INT2NUM(yylineno), $2, Qnil, $3);
|
336
347
|
}
|
348
|
+
| CLASS const_identifier {
|
349
|
+
$$ = rb_funcall(self, rb_intern("ast:class:parent:"), 3, INT2NUM(yylineno), $2, Qnil);
|
350
|
+
}
|
337
351
|
;
|
338
352
|
|
339
353
|
class_super: CLASS const_identifier COLON const_identifier expression_block {
|
340
354
|
$$ = rb_funcall(self, rb_intern("ast:class:parent:body:"), 4, INT2NUM(yylineno), $2, $4, $5);
|
341
355
|
}
|
356
|
+
| CLASS const_identifier COLON const_identifier {
|
357
|
+
$$ = rb_funcall(self, rb_intern("ast:class:parent:"), 3, INT2NUM(yylineno), $2, $4);
|
358
|
+
}
|
342
359
|
;
|
343
360
|
|
344
361
|
method_def: method_w_args
|
@@ -384,40 +401,60 @@ method_args_default: method_arg_default {
|
|
384
401
|
method_w_args: def method_args expression_block {
|
385
402
|
$$ = rb_funcall(self, rb_intern("ast:method:expand:access:"), 4, INT2NUM(yylineno), $2, $3, $1);
|
386
403
|
}
|
404
|
+
| def method_args {
|
405
|
+
$$ = rb_funcall(self, rb_intern("ast:method:expand:access:"), 4, INT2NUM(yylineno), $2, Qnil, $1);
|
406
|
+
}
|
387
407
|
;
|
388
408
|
|
389
409
|
|
390
410
|
method_no_args: def identifier expression_block {
|
391
411
|
$$ = rb_funcall(self, rb_intern("ast:method:body:access:"), 4, INT2NUM(yylineno), $2, $3, $1);
|
392
412
|
}
|
413
|
+
| def identifier {
|
414
|
+
$$ = rb_funcall(self, rb_intern("ast:method:body:access:"), 4, INT2NUM(yylineno), $2, Qnil, $1);
|
415
|
+
}
|
393
416
|
;
|
394
417
|
|
395
418
|
|
396
419
|
class_method_w_args: def any_identifier method_args expression_block {
|
397
420
|
$$ = rb_funcall(self, rb_intern("ast:method:expand:access:owner:"), 5, INT2NUM(yylineno), $3, $4, $1, $2);
|
398
421
|
}
|
422
|
+
| def any_identifier method_args {
|
423
|
+
$$ = rb_funcall(self, rb_intern("ast:method:expand:access:owner:"), 5, INT2NUM(yylineno), $3, Qnil, $1, $2);
|
424
|
+
}
|
399
425
|
;
|
400
426
|
|
401
427
|
class_method_no_args: def any_identifier identifier expression_block {
|
402
428
|
$$ = rb_funcall(self, rb_intern("ast:method:body:access:owner:"), 5, INT2NUM(yylineno), $3, $4, $1, $2);
|
403
429
|
}
|
430
|
+
| def any_identifier identifier {
|
431
|
+
$$ = rb_funcall(self, rb_intern("ast:method:body:access:owner:"), 5, INT2NUM(yylineno), $3, Qnil, $1, $2);
|
432
|
+
}
|
404
433
|
;
|
405
434
|
|
406
435
|
operator_def: def operator identifier expression_block {
|
407
436
|
$$ = rb_funcall(self, rb_intern("ast:oper:arg:body:access:"), 5, INT2NUM(yylineno), $2, $3, $4, $1);
|
408
437
|
}
|
409
|
-
| def LBRACKET RBRACKET
|
438
|
+
| def LBRACKET identifier RBRACKET expression_block {
|
410
439
|
$$ = rb_funcall(self, rb_intern("ast:oper:arg:body:access:"), 5,
|
411
|
-
INT2NUM(yylineno), fy_terminal_node_from(self, "ast:identifier:", "[]"), $
|
440
|
+
INT2NUM(yylineno), fy_terminal_node_from(self, "ast:identifier:", "[]"), $3, $5, $1);
|
441
|
+
}
|
442
|
+
| def LBRACKET identifier RBRACKET COLON identifier expression_block {
|
443
|
+
$$ = rb_funcall(self, rb_intern("ast:oper:arg:arg:body:access:"), 6,
|
444
|
+
INT2NUM(yylineno), fy_terminal_node_from(self, "ast:identifier:", "[]:"), $3, $6, $7, $1);
|
412
445
|
}
|
413
446
|
;
|
414
447
|
|
415
448
|
class_operator_def: def any_identifier operator identifier expression_block {
|
416
449
|
$$ = rb_funcall(self, rb_intern("ast:oper:arg:body:access:owner:"), 6, INT2NUM(yylineno), $3, $4, $5, $1, $2);
|
417
450
|
}
|
418
|
-
| def any_identifier LBRACKET RBRACKET
|
451
|
+
| def any_identifier LBRACKET identifier RBRACKET expression_block {
|
419
452
|
$$ = rb_funcall(self, rb_intern("ast:oper:arg:body:access:owner:"), 6,
|
420
|
-
INT2NUM(yylineno), fy_terminal_node_from(self, "ast:identifier:", "[]"), $
|
453
|
+
INT2NUM(yylineno), fy_terminal_node_from(self, "ast:identifier:", "[]"), $4, $6, $1, $2);
|
454
|
+
}
|
455
|
+
| def any_identifier LBRACKET identifier RBRACKET COLON identifier expression_block {
|
456
|
+
$$ = rb_funcall(self, rb_intern("ast:oper:arg:arg:body:access:owner:"), 7,
|
457
|
+
INT2NUM(yylineno), fy_terminal_node_from(self, "ast:identifier:", "[]:"), $4, $7, $8, $1, $2);
|
421
458
|
}
|
422
459
|
;
|
423
460
|
|
@@ -451,6 +488,10 @@ operator_send: exp operator arg_exp {
|
|
451
488
|
$$ = rb_funcall(self, rb_intern("ast:oper:arg:to:"), 4,
|
452
489
|
INT2NUM(yylineno), fy_terminal_node_from(self, "ast:identifier:", "[]"), $3, $1);
|
453
490
|
}
|
491
|
+
| exp LBRACKET exp RBRACKET COLON arg_exp {
|
492
|
+
$$ = rb_funcall(self, rb_intern("ast:oper:arg:arg:to:"), 5,
|
493
|
+
INT2NUM(yylineno), fy_terminal_node_from(self, "ast:identifier:", "[]:"), $3, $6, $1);
|
494
|
+
}
|
454
495
|
| operator arg_exp {
|
455
496
|
$$ = rb_funcall(self, rb_intern("ast:oper:arg:"), 3, INT2NUM(yylineno), $1, $2);
|
456
497
|
}
|
@@ -484,6 +525,12 @@ message_send: unary_send
|
|
484
525
|
| send_args {
|
485
526
|
$$ = rb_funcall(self, rb_intern("ast:send:"), 2, INT2NUM(yylineno), $1);
|
486
527
|
}
|
528
|
+
| unary_send FUTURE_SEND send_args {
|
529
|
+
$$ = rb_funcall(self, rb_intern("ast:future_send:to:"), 3, INT2NUM(yylineno), $3, $1);
|
530
|
+
}
|
531
|
+
| unary_send ASYNC_SEND send_args {
|
532
|
+
$$ = rb_funcall(self, rb_intern("ast:async_send:to:"), 3, INT2NUM(yylineno), $3, $1);
|
533
|
+
}
|
487
534
|
| exp FUTURE_SEND send_args {
|
488
535
|
$$ = rb_funcall(self, rb_intern("ast:future_send:to:"), 3, INT2NUM(yylineno), $3, $1);
|
489
536
|
}
|
@@ -698,10 +745,10 @@ empty_array: LBRACKET space RBRACKET {
|
|
698
745
|
}
|
699
746
|
;
|
700
747
|
|
701
|
-
hash_literal:
|
748
|
+
hash_literal: LEFTHASH space key_value_list space RIGHTHASH {
|
702
749
|
$$ = rb_funcall(self, rb_intern("ast:hash:"), 2, INT2NUM(yylineno), $3);
|
703
750
|
}
|
704
|
-
|
|
751
|
+
| LEFTHASH space RIGHTHASH {
|
705
752
|
$$ = rb_funcall(self, rb_intern("ast:hash:"), 2, INT2NUM(yylineno), Qnil);
|
706
753
|
}
|
707
754
|
;
|
data/lib/parser/methods.fy
CHANGED
@@ -74,20 +74,19 @@ class Fancy {
|
|
74
74
|
interpol_str = matches[2]
|
75
75
|
suffix = matches[3]
|
76
76
|
|
77
|
-
binding = AST MessageSend new: line message: (ast: line identifier: "binding") to: (AST Self new: line) args: (AST RubyArgs new: line args: [])
|
78
|
-
evalstr = AST StringLiteral new: line value: interpol_str
|
79
|
-
msg = ast: line identifier: "eval:binding:"
|
80
|
-
binding_send = AST MessageSend new: line message: msg to: (ast: line identifier: "Fancy") \
|
81
|
-
args: (AST MessageArgs new: line args: [evalstr, binding])
|
82
|
-
|
83
77
|
prefix_str = ast: line string: (" " + prefix + " ") # hack, pre- & append " " since it gets removed
|
84
78
|
suffix_str = ast: line string: (" " + suffix + " ")
|
79
|
+
interpol_ast = AST StringInterpolation new: line code: interpol_str
|
85
80
|
# create messagesend to concatenate:
|
86
81
|
concat_ident = ast: line identifier: "++"
|
87
|
-
|
88
|
-
|
82
|
+
interpol_send = AST MessageSend new: line message: concat_ident to: prefix_str args: (AST MessageArgs new: line args: [interpol_ast])
|
83
|
+
|
84
|
+
# don't concatenate suffix if it's empty..
|
85
|
+
unless: (suffix == "") do: {
|
86
|
+
interpol_send = AST MessageSend new: line message: concat_ident to: interpol_send args: (AST MessageArgs new: line args: [suffix_str])
|
87
|
+
}
|
89
88
|
|
90
|
-
|
89
|
+
interpol_send # this shall get returned, yo
|
91
90
|
case _ ->
|
92
91
|
AST StringLiteral new: line value: str
|
93
92
|
}
|
@@ -164,6 +163,13 @@ class Fancy {
|
|
164
163
|
ast: line send: message to: receiver
|
165
164
|
}
|
166
165
|
|
166
|
+
def ast: line oper: oper arg: arg1 arg: arg2 to: receiver (AST Self new: line) {
|
167
|
+
m1 = SelectorValue new(oper, arg1)
|
168
|
+
m2 = SelectorValue new(ast: line identifier: "", arg2)
|
169
|
+
message = [m1, m2]
|
170
|
+
ast: line send: message to: receiver
|
171
|
+
}
|
172
|
+
|
167
173
|
def ast: line future_oper: oper arg: arg to: receiver {
|
168
174
|
oper_send = ast: line oper: oper arg: arg to: receiver
|
169
175
|
AST FutureSend new: line message_send: oper_send
|
@@ -248,6 +254,11 @@ class Fancy {
|
|
248
254
|
ast: line method: margs body: body access: access owner: owner
|
249
255
|
}
|
250
256
|
|
257
|
+
def ast: line oper: op arg: arg1 arg: arg2 body: body access: access ('public) owner: owner (nil) {
|
258
|
+
margs = [SelectorVarDefault new(op, arg1, nil), SelectorVarDefault new(ast: line identifier: "", arg2, nil)]
|
259
|
+
ast: line method: margs body: body access: access owner: owner
|
260
|
+
}
|
261
|
+
|
251
262
|
def ast: line method: margs body: body access: access ('public) owner: owner (nil) {
|
252
263
|
if: (margs is_a?(AST Identifier)) then: {
|
253
264
|
args = AST MethodArgs new: line args: []
|
@@ -296,11 +307,7 @@ class Fancy {
|
|
296
307
|
AST BlockLiteral new: line args: args body: body
|
297
308
|
}
|
298
309
|
|
299
|
-
def ast: line
|
300
|
-
AST Require new: line file: file
|
301
|
-
}
|
302
|
-
|
303
|
-
def ast: line class: name parent: parent body: body {
|
310
|
+
def ast: line class: name parent: parent body: body (AST ExpressionList new: line) {
|
304
311
|
AST ClassDef new: line name: name parent: parent body: body
|
305
312
|
}
|
306
313
|
|
@@ -330,6 +337,18 @@ class Fancy {
|
|
330
337
|
AST RubyArgs new: line args: args block: block
|
331
338
|
}
|
332
339
|
|
340
|
+
def ast: line string_value: string {
|
341
|
+
string
|
342
|
+
}
|
343
|
+
|
344
|
+
def ast: line goto: label_name {
|
345
|
+
AST Goto new: line label_name: label_name
|
346
|
+
}
|
347
|
+
|
348
|
+
def ast: line label: label {
|
349
|
+
AST Label new: line name: label
|
350
|
+
}
|
351
|
+
|
333
352
|
def ast: line parse_error: text {
|
334
353
|
ParseError new: line message: text filename: @filename . raise!
|
335
354
|
}
|