fancy 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +1 -0
- data/bin/fspec +3 -1
- data/boot/code_loader.rb +5 -1
- data/boot/compiler/parser/ext/fancy_parser.bundle +0 -0
- data/boot/fancy_ext.rb +2 -0
- data/boot/fancy_ext/bootstrap.rb +6 -0
- data/boot/fancy_ext/symbol.rb +9 -0
- data/boot/fancy_ext/thread.rb +22 -1
- data/boot/load.rb +1 -0
- data/boot/rbx-compiler/parser/Makefile +156 -0
- data/boot/rbx-compiler/parser/fancy_parser.bundle +0 -0
- data/boot/rbx-compiler/parser/lexer.c +2310 -0
- data/boot/rbx-compiler/parser/lexer.h +315 -0
- data/boot/rbx-compiler/parser/parser.c +2946 -0
- data/boot/rbx-compiler/parser/parser.h +151 -0
- data/doc/api/fancy.jsonp +1 -1
- data/doc/features.md +8 -0
- data/examples/actors.fy +5 -9
- data/examples/actors_primitive.fy +4 -3
- data/examples/actors_ring.fy +15 -14
- data/examples/dynamic.fy +8 -0
- data/examples/dynamic_output.fy +15 -0
- data/examples/parsing.fy +1 -0
- data/examples/person.fy +1 -2
- data/lib/array.fy +49 -11
- data/lib/block.fy +18 -24
- data/lib/boot.fy +1 -1
- data/lib/class.fy +6 -6
- data/lib/compiler/ast.fy +0 -1
- data/lib/compiler/ast/assign.fy +25 -0
- data/lib/compiler/ast/block.fy +1 -0
- data/lib/compiler/ast/identifier.fy +16 -0
- data/lib/compiler/ast/literals.fy +4 -0
- data/lib/compiler/ast/message_send.fy +16 -1
- data/lib/enumerable.fy +45 -18
- data/lib/enumerator.fy +15 -15
- data/lib/false_class.fy +8 -0
- data/lib/fancy_spec.fy +20 -20
- data/lib/future.fy +35 -18
- data/lib/hash.fy +2 -2
- data/lib/integer.fy +1 -17
- data/lib/iteration.fy +36 -36
- data/lib/object.fy +65 -30
- data/lib/package.fy +2 -2
- data/lib/package/installer.fy +6 -0
- data/lib/parser/ext/Makefile +156 -0
- data/lib/parser/ext/fancy_parser.bundle +0 -0
- data/lib/parser/ext/lexer.c +2392 -0
- data/lib/parser/ext/lexer.h +315 -0
- data/lib/parser/ext/lexer.lex +0 -10
- data/lib/parser/ext/parser.c +3251 -0
- data/lib/parser/ext/parser.h +161 -0
- data/lib/parser/ext/parser.y +0 -22
- data/lib/parser/methods.fy +1 -13
- data/lib/range.fy +3 -3
- data/lib/rbx.fy +1 -0
- data/lib/rbx/actor.fy +4 -4
- data/lib/rbx/alpha.fy +6 -0
- data/lib/rbx/array.fy +5 -44
- data/lib/rbx/bignum.fy +1 -12
- data/lib/rbx/block.fy +25 -0
- data/lib/rbx/class.fy +1 -7
- data/lib/rbx/date.fy +1 -5
- data/lib/rbx/file.fy +1 -4
- data/lib/rbx/fixnum.fy +4 -16
- data/lib/rbx/float.fy +1 -10
- data/lib/rbx/integer.fy +14 -2
- data/lib/rbx/io.fy +1 -5
- data/lib/rbx/mutex.fy +30 -0
- data/lib/rbx/object.fy +5 -11
- data/lib/rbx/process.fy +13 -0
- data/lib/rbx/range.fy +1 -5
- data/lib/rbx/string.fy +4 -11
- data/lib/rbx/thread.fy +9 -0
- data/lib/rbx/time.fy +1 -7
- data/lib/stack.fy +1 -1
- data/lib/string.fy +9 -9
- data/lib/symbol.fy +12 -7
- data/lib/tuple.fy +18 -3
- data/lib/vars.fy +3 -0
- data/ruby_lib/fspec +2 -2
- data/ruby_lib/fyi +2 -2
- data/ruby_lib/ifancy +2 -2
- data/tests/array.fy +25 -1
- data/tests/assignment.fy +55 -0
- data/tests/future.fy +28 -0
- data/tests/set.fy +20 -0
- data/tests/stack.fy +46 -0
- data/tests/string.fy +1 -1
- data/tests/tuple.fy +22 -0
- data/tools/fancy-mode.el +1 -1
- metadata +26 -8
- data/lib/compiler/ast/goto.fy +0 -46
- data/lib/message.fy +0 -6
@@ -0,0 +1,161 @@
|
|
1
|
+
/* A Bison parser, made by GNU Bison 2.3. */
|
2
|
+
|
3
|
+
/* Skeleton interface for Bison's Yacc-like parsers in C
|
4
|
+
|
5
|
+
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
6
|
+
Free Software Foundation, Inc.
|
7
|
+
|
8
|
+
This program is free software; you can redistribute it and/or modify
|
9
|
+
it under the terms of the GNU General Public License as published by
|
10
|
+
the Free Software Foundation; either version 2, or (at your option)
|
11
|
+
any later version.
|
12
|
+
|
13
|
+
This program is distributed in the hope that it will be useful,
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
GNU General Public License for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU General Public License
|
19
|
+
along with this program; if not, write to the Free Software
|
20
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
21
|
+
Boston, MA 02110-1301, USA. */
|
22
|
+
|
23
|
+
/* As a special exception, you may create a larger work that contains
|
24
|
+
part or all of the Bison parser skeleton and distribute that work
|
25
|
+
under terms of your choice, so long as that work isn't itself a
|
26
|
+
parser generator using the skeleton or a modified version thereof
|
27
|
+
as a parser skeleton. Alternatively, if you modify or redistribute
|
28
|
+
the parser skeleton itself, you may (at your option) remove this
|
29
|
+
special exception, which will cause the skeleton and the resulting
|
30
|
+
Bison output files to be licensed under the GNU General Public
|
31
|
+
License without this special exception.
|
32
|
+
|
33
|
+
This special exception was added by the Free Software Foundation in
|
34
|
+
version 2.2 of Bison. */
|
35
|
+
|
36
|
+
/* Tokens. */
|
37
|
+
#ifndef YYTOKENTYPE
|
38
|
+
# define YYTOKENTYPE
|
39
|
+
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
40
|
+
know about them. */
|
41
|
+
enum yytokentype {
|
42
|
+
LPAREN = 258,
|
43
|
+
RPAREN = 259,
|
44
|
+
FUTURE_SEND = 260,
|
45
|
+
ASYNC_SEND = 261,
|
46
|
+
AT_LCURLY = 262,
|
47
|
+
LCURLY = 263,
|
48
|
+
RCURLY = 264,
|
49
|
+
LBRACKET = 265,
|
50
|
+
RBRACKET = 266,
|
51
|
+
LEFTHASH = 267,
|
52
|
+
RIGHTHASH = 268,
|
53
|
+
STAB = 269,
|
54
|
+
ARROW = 270,
|
55
|
+
THIN_ARROW = 271,
|
56
|
+
COMMA = 272,
|
57
|
+
SEMI = 273,
|
58
|
+
NL = 274,
|
59
|
+
COLON = 275,
|
60
|
+
RETURN_LOCAL = 276,
|
61
|
+
RETURN = 277,
|
62
|
+
TRY = 278,
|
63
|
+
CATCH = 279,
|
64
|
+
FINALLY = 280,
|
65
|
+
RETRY = 281,
|
66
|
+
SUPER = 282,
|
67
|
+
CLASS = 283,
|
68
|
+
DEF = 284,
|
69
|
+
DOT = 285,
|
70
|
+
DOLLAR = 286,
|
71
|
+
EQUALS = 287,
|
72
|
+
MATCH = 288,
|
73
|
+
CASE = 289,
|
74
|
+
IDENTIFIER = 290,
|
75
|
+
SELECTOR = 291,
|
76
|
+
RUBY_SEND_OPEN = 292,
|
77
|
+
RUBY_OPER_OPEN = 293,
|
78
|
+
CONSTANT = 294,
|
79
|
+
INTEGER_LITERAL = 295,
|
80
|
+
HEX_LITERAL = 296,
|
81
|
+
OCT_LITERAL = 297,
|
82
|
+
BIN_LITERAL = 298,
|
83
|
+
DOUBLE_LITERAL = 299,
|
84
|
+
STRING_LITERAL = 300,
|
85
|
+
MULTI_STRING_LITERAL = 301,
|
86
|
+
SYMBOL_LITERAL = 302,
|
87
|
+
REGEX_LITERAL = 303,
|
88
|
+
OPERATOR = 304,
|
89
|
+
BACKTICK_LITERAL = 305
|
90
|
+
};
|
91
|
+
#endif
|
92
|
+
/* Tokens. */
|
93
|
+
#define LPAREN 258
|
94
|
+
#define RPAREN 259
|
95
|
+
#define FUTURE_SEND 260
|
96
|
+
#define ASYNC_SEND 261
|
97
|
+
#define AT_LCURLY 262
|
98
|
+
#define LCURLY 263
|
99
|
+
#define RCURLY 264
|
100
|
+
#define LBRACKET 265
|
101
|
+
#define RBRACKET 266
|
102
|
+
#define LEFTHASH 267
|
103
|
+
#define RIGHTHASH 268
|
104
|
+
#define STAB 269
|
105
|
+
#define ARROW 270
|
106
|
+
#define THIN_ARROW 271
|
107
|
+
#define COMMA 272
|
108
|
+
#define SEMI 273
|
109
|
+
#define NL 274
|
110
|
+
#define COLON 275
|
111
|
+
#define RETURN_LOCAL 276
|
112
|
+
#define RETURN 277
|
113
|
+
#define TRY 278
|
114
|
+
#define CATCH 279
|
115
|
+
#define FINALLY 280
|
116
|
+
#define RETRY 281
|
117
|
+
#define SUPER 282
|
118
|
+
#define CLASS 283
|
119
|
+
#define DEF 284
|
120
|
+
#define DOT 285
|
121
|
+
#define DOLLAR 286
|
122
|
+
#define EQUALS 287
|
123
|
+
#define MATCH 288
|
124
|
+
#define CASE 289
|
125
|
+
#define IDENTIFIER 290
|
126
|
+
#define SELECTOR 291
|
127
|
+
#define RUBY_SEND_OPEN 292
|
128
|
+
#define RUBY_OPER_OPEN 293
|
129
|
+
#define CONSTANT 294
|
130
|
+
#define INTEGER_LITERAL 295
|
131
|
+
#define HEX_LITERAL 296
|
132
|
+
#define OCT_LITERAL 297
|
133
|
+
#define BIN_LITERAL 298
|
134
|
+
#define DOUBLE_LITERAL 299
|
135
|
+
#define STRING_LITERAL 300
|
136
|
+
#define MULTI_STRING_LITERAL 301
|
137
|
+
#define SYMBOL_LITERAL 302
|
138
|
+
#define REGEX_LITERAL 303
|
139
|
+
#define OPERATOR 304
|
140
|
+
#define BACKTICK_LITERAL 305
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
146
|
+
typedef union YYSTYPE
|
147
|
+
#line 18 "/Users/backtype/projects/fancy/lib/parser/ext/parser.y"
|
148
|
+
{
|
149
|
+
VALUE object;
|
150
|
+
ID symbol;
|
151
|
+
}
|
152
|
+
/* Line 1529 of yacc.c. */
|
153
|
+
#line 154 "/Users/backtype/projects/fancy/lib/parser/ext/parser.h"
|
154
|
+
YYSTYPE;
|
155
|
+
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
156
|
+
# define YYSTYPE_IS_DECLARED 1
|
157
|
+
# define YYSTYPE_IS_TRIVIAL 1
|
158
|
+
#endif
|
159
|
+
|
160
|
+
extern YYSTYPE yylval;
|
161
|
+
|
data/lib/parser/ext/parser.y
CHANGED
@@ -55,8 +55,6 @@ extern char *yytext;
|
|
55
55
|
%token MATCH
|
56
56
|
%token CASE
|
57
57
|
%token IDENTIFIER
|
58
|
-
%token GOTO
|
59
|
-
%token LABEL
|
60
58
|
%token SELECTOR
|
61
59
|
%token RUBY_SEND_OPEN
|
62
60
|
%token RUBY_OPER_OPEN
|
@@ -90,9 +88,6 @@ extern char *yytext;
|
|
90
88
|
|
91
89
|
|
92
90
|
%type <object> identifier
|
93
|
-
%type <object> goto_statement
|
94
|
-
%type <object> label_literal
|
95
|
-
%type <object> label_statement
|
96
91
|
%type <object> any_identifier
|
97
92
|
%type <object> constant
|
98
93
|
%type <object> literal_value
|
@@ -219,23 +214,6 @@ partial_expression_block: AT_LCURLY space expression_list space RCURLY {
|
|
219
214
|
statement: assignment
|
220
215
|
| return_local_statement
|
221
216
|
| return_statement
|
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
|
-
}
|
239
217
|
;
|
240
218
|
|
241
219
|
primary: any_identifier
|
data/lib/parser/methods.fy
CHANGED
@@ -337,20 +337,8 @@ class Fancy {
|
|
337
337
|
AST RubyArgs new: line args: args block: block
|
338
338
|
}
|
339
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
|
-
|
352
340
|
def ast: line parse_error: text {
|
353
|
-
ParseError new: line message: text filename: @filename . raise!
|
341
|
+
ParseError new: (line - 1) message: text filename: @filename . raise!
|
354
342
|
}
|
355
343
|
|
356
344
|
def ast: line file_error: text {
|
data/lib/range.fy
CHANGED
@@ -3,9 +3,9 @@ class Range {
|
|
3
3
|
Class of Range values. Are created by using Range literal syntax in Fancy.
|
4
4
|
|
5
5
|
Example:
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
(10..100) # Range from 10 to 100
|
7
|
+
# the following code does the same as above:
|
8
|
+
Range new: 10 to: 100
|
9
9
|
"""
|
10
10
|
|
11
11
|
include: FancyEnumerable
|
data/lib/rbx.fy
CHANGED
data/lib/rbx/actor.fy
CHANGED
@@ -41,11 +41,11 @@ class Actor {
|
|
41
41
|
|
42
42
|
Example usage:
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
Actor spawn: {
|
45
|
+
loop: {
|
46
|
+
Actor receive println # print all incoming messages
|
47
|
+
}
|
47
48
|
}
|
48
|
-
}
|
49
49
|
"""
|
50
50
|
|
51
51
|
Actor spawn(&block)
|
data/lib/rbx/alpha.fy
CHANGED
data/lib/rbx/array.fy
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
class Array {
|
2
|
-
|
3
|
-
ruby_alias: '<<
|
4
|
-
ruby_alias: 'pop
|
5
|
-
ruby_alias: 'last
|
6
|
-
ruby_alias: 'shift
|
2
|
+
ruby_aliases: [ '==, '<<, 'pop, 'last, 'shift ]
|
7
3
|
|
8
4
|
forwards_unary_ruby_methods
|
9
5
|
|
@@ -61,6 +57,8 @@ class Array {
|
|
61
57
|
at(idx)
|
62
58
|
}
|
63
59
|
|
60
|
+
alias_method('at_put, '[]=)
|
61
|
+
|
64
62
|
def [idx]: obj {
|
65
63
|
"""
|
66
64
|
@idx Index to set a value for.
|
@@ -69,7 +67,8 @@ class Array {
|
|
69
67
|
|
70
68
|
Inserts a given object at a given index (position) in the Array.
|
71
69
|
"""
|
72
|
-
|
70
|
+
|
71
|
+
at_put(idx, obj)
|
73
72
|
}
|
74
73
|
|
75
74
|
alias_method: 'at:put: for: '[]:
|
@@ -94,44 +93,6 @@ class Array {
|
|
94
93
|
last(count)
|
95
94
|
}
|
96
95
|
|
97
|
-
def any?: block {
|
98
|
-
"""
|
99
|
-
@block Predicate @Block@ to be called for each element until it returns @true for any one of them.
|
100
|
-
@return @true if any element in @self yields @true for @block, @false otherwise.
|
101
|
-
|
102
|
-
Takes condition-block and returns @true if any element meets it.
|
103
|
-
"""
|
104
|
-
any?(&block)
|
105
|
-
}
|
106
|
-
|
107
|
-
def all?: block {
|
108
|
-
"""
|
109
|
-
@block Predicate @Block@ to be called for each element until it returns @false for any one of them.
|
110
|
-
@return @true if all elements in @self yield @true for @block, @false otherwise.
|
111
|
-
|
112
|
-
Takes condition-block and returns @true if all elements meet it.
|
113
|
-
"""
|
114
|
-
all?(&block)
|
115
|
-
}
|
116
|
-
|
117
|
-
def reject: block {
|
118
|
-
"""
|
119
|
-
Returns a new Array with all the elements which yield nil or false
|
120
|
-
when called with the given Block.
|
121
|
-
"""
|
122
|
-
|
123
|
-
reject(&block)
|
124
|
-
}
|
125
|
-
|
126
|
-
def reject!: block {
|
127
|
-
"""
|
128
|
-
Same as Array#reject: but doing so in-place (destructive).
|
129
|
-
"""
|
130
|
-
|
131
|
-
reject!(&block)
|
132
|
-
return self
|
133
|
-
}
|
134
|
-
|
135
96
|
def join: join_str {
|
136
97
|
"""
|
137
98
|
@join_str @String@ by which to @join all elements in @self into a new @String@.
|
data/lib/rbx/bignum.fy
CHANGED
@@ -5,18 +5,7 @@ class Bignum {
|
|
5
5
|
|
6
6
|
include: Number
|
7
7
|
|
8
|
-
|
9
|
-
ruby_alias: '-
|
10
|
-
ruby_alias: '+
|
11
|
-
ruby_alias: '*
|
12
|
-
ruby_alias: '/
|
13
|
-
ruby_alias: '<
|
14
|
-
ruby_alias: '>
|
15
|
-
ruby_alias: '<=
|
16
|
-
ruby_alias: '>=
|
17
|
-
ruby_alias: '===
|
18
|
-
ruby_alias: '**
|
19
|
-
ruby_alias: '&
|
8
|
+
ruby_aliases: [ '==, '-, '+, '*, '/, '<, '>, '<=, '>=, '===, '**, '& ]
|
20
9
|
|
21
10
|
forwards_unary_ruby_methods
|
22
11
|
|
data/lib/rbx/block.fy
CHANGED
@@ -4,6 +4,31 @@ class Block {
|
|
4
4
|
forwards_unary_ruby_methods
|
5
5
|
metaclass forwards_unary_ruby_methods
|
6
6
|
|
7
|
+
# low level while_true: implementation
|
8
|
+
# use direct bytecode generation for speed purposes
|
9
|
+
# this gives us good speed in loops
|
10
|
+
dynamic_method('while_true_impl:) |g| {
|
11
|
+
start = g new_label()
|
12
|
+
end = g new_label()
|
13
|
+
g total_args=(1)
|
14
|
+
|
15
|
+
start set!()
|
16
|
+
g push_self()
|
17
|
+
g send('call, 0)
|
18
|
+
g set_local(1)
|
19
|
+
g gif(end)
|
20
|
+
g push_local(0)
|
21
|
+
g push_local(1)
|
22
|
+
g send('call, 1)
|
23
|
+
g pop()
|
24
|
+
g check_interrupts()
|
25
|
+
g goto(start)
|
26
|
+
|
27
|
+
end set!()
|
28
|
+
g push_nil()
|
29
|
+
g ret()
|
30
|
+
}
|
31
|
+
|
7
32
|
def receiver {
|
8
33
|
"""
|
9
34
|
@return Receiver object of a @Block@.
|
data/lib/rbx/class.fy
CHANGED
@@ -1,11 +1,5 @@
|
|
1
1
|
class Class {
|
2
|
-
|
3
|
-
ruby_alias: '===
|
4
|
-
ruby_alias: 'ancestors
|
5
|
-
ruby_alias: 'instance_methods
|
6
|
-
ruby_alias: 'methods
|
7
|
-
ruby_alias: 'inspect
|
8
|
-
ruby_alias: 'to_s
|
2
|
+
ruby_aliases: [ 'superclass, '===, 'ancestors, 'instance_methods, 'methods, 'inspect, 'to_s ]
|
9
3
|
|
10
4
|
def new {
|
11
5
|
"""
|
data/lib/rbx/date.fy
CHANGED
@@ -9,11 +9,7 @@ class Date {
|
|
9
9
|
metaclass forwards_unary_ruby_methods
|
10
10
|
|
11
11
|
metaclass ruby_alias: 'today
|
12
|
-
|
13
|
-
ruby_alias: '-
|
14
|
-
ruby_alias: '+
|
15
|
-
ruby_alias: '<
|
16
|
-
ruby_alias: '>
|
12
|
+
ruby_aliases: [ '==, '-, '+, '<, '> ]
|
17
13
|
|
18
14
|
def != other {
|
19
15
|
self == other not
|
data/lib/rbx/file.fy
CHANGED