iv-phonic 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/ext/include/iv/ast-factory.h +42 -30
- data/ext/include/iv/ast-fwd.h +22 -12
- data/ext/include/iv/ast-serializer.h +26 -32
- data/ext/include/iv/ast-visitor.h +0 -2
- data/ext/include/iv/ast.h +122 -244
- data/ext/include/iv/lexer.h +1 -1
- data/ext/include/iv/parser.h +199 -193
- data/ext/iv/phonic/creator.h +0 -8
- data/ext/iv/phonic/factory.h +45 -32
- data/ext/iv/phonic/phonic.cc +0 -47
- metadata +3 -3
data/ext/iv/phonic/creator.h
CHANGED
@@ -512,14 +512,6 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
|
|
512
512
|
ret_ = hash;
|
513
513
|
}
|
514
514
|
|
515
|
-
void Visit(const Declaration* decl) {
|
516
|
-
UNREACHABLE();
|
517
|
-
}
|
518
|
-
|
519
|
-
void Visit(const CaseClause* clause) {
|
520
|
-
UNREACHABLE();
|
521
|
-
}
|
522
|
-
|
523
515
|
private:
|
524
516
|
VALUE ret_;
|
525
517
|
};
|
data/ext/iv/phonic/factory.h
CHANGED
@@ -23,18 +23,9 @@ class AstFactory : public core::Space<2> {
|
|
23
23
|
false_instance_(new(this)FalseLiteral()) {
|
24
24
|
}
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
}
|
30
|
-
|
31
|
-
Identifier* NewIdentifier(const std::vector<uc16>& buffer) {
|
32
|
-
Identifier* ident = new (this) Identifier(buffer, this);
|
33
|
-
return ident;
|
34
|
-
}
|
35
|
-
|
36
|
-
Identifier* NewIdentifier(const std::vector<char>& buffer) {
|
37
|
-
Identifier* ident = new (this) Identifier(buffer, this);
|
26
|
+
template<typename Range>
|
27
|
+
Identifier* NewIdentifier(const Range& range) {
|
28
|
+
Identifier* ident = new(this)Identifier(range, this);
|
38
29
|
return ident;
|
39
30
|
}
|
40
31
|
|
@@ -57,8 +48,10 @@ class AstFactory : public core::Space<2> {
|
|
57
48
|
// // TODO(Constellation) Little Endian?
|
58
49
|
// int r = onig_new(®,
|
59
50
|
// reinterpret_cast<const OnigUChar*>(content.data()),
|
60
|
-
// reinterpret_cast<const OnigUChar*>(
|
61
|
-
//
|
51
|
+
// reinterpret_cast<const OnigUChar*>(
|
52
|
+
// content.data()+content.size()),
|
53
|
+
// ONIG_OPTION_DEFAULT,
|
54
|
+
// rb_enc_get(Encoding::UTF16LEEncoding()),
|
62
55
|
// ONIG_SYNTAX_DEFAULT, &einfo);
|
63
56
|
// if (r != ONIG_NORMAL) {
|
64
57
|
// return NULL;
|
@@ -128,36 +121,50 @@ class AstFactory : public core::Space<2> {
|
|
128
121
|
return new (this) Declaration(name, expr);
|
129
122
|
}
|
130
123
|
|
131
|
-
IfStatement* NewIfStatement(Expression* cond,
|
132
|
-
|
124
|
+
IfStatement* NewIfStatement(Expression* cond,
|
125
|
+
Statement* then_statement,
|
126
|
+
Statement* else_statement) {
|
127
|
+
return new (this) IfStatement(cond,
|
128
|
+
then_statement,
|
129
|
+
else_statement);
|
133
130
|
}
|
134
131
|
|
135
|
-
DoWhileStatement* NewDoWhileStatement(
|
136
|
-
|
132
|
+
DoWhileStatement* NewDoWhileStatement(Statement* body,
|
133
|
+
Expression* cond) {
|
134
|
+
return new (this) DoWhileStatement(body, cond);
|
137
135
|
}
|
138
136
|
|
139
|
-
WhileStatement* NewWhileStatement(
|
140
|
-
|
137
|
+
WhileStatement* NewWhileStatement(Statement* body,
|
138
|
+
Expression* cond) {
|
139
|
+
return new (this) WhileStatement(body, cond);
|
141
140
|
}
|
142
141
|
|
143
|
-
ForInStatement* NewForInStatement(Statement*
|
144
|
-
|
142
|
+
ForInStatement* NewForInStatement(Statement* body,
|
143
|
+
Statement* each,
|
144
|
+
Expression* enumerable) {
|
145
|
+
return new (this) ForInStatement(body, each, enumerable);
|
145
146
|
}
|
146
147
|
|
147
148
|
ExpressionStatement* NewExpressionStatement(Expression* expr) {
|
148
149
|
return new (this) ExpressionStatement(expr);
|
149
150
|
}
|
150
151
|
|
151
|
-
ForStatement* NewForStatement(
|
152
|
-
|
152
|
+
ForStatement* NewForStatement(Statement* body,
|
153
|
+
Statement* init,
|
154
|
+
Expression* cond,
|
155
|
+
Statement* next) {
|
156
|
+
return new (this) ForStatement(body, init, cond, next);
|
153
157
|
}
|
154
158
|
|
155
|
-
|
156
|
-
|
159
|
+
|
160
|
+
ContinueStatement* NewContinueStatement(Identifier* label,
|
161
|
+
IterationStatement** target) {
|
162
|
+
return new (this) ContinueStatement(label, target);
|
157
163
|
}
|
158
164
|
|
159
|
-
BreakStatement* NewBreakStatement(
|
160
|
-
|
165
|
+
BreakStatement* NewBreakStatement(Identifier* label,
|
166
|
+
BreakableStatement** target) {
|
167
|
+
return new (this) BreakStatement(label, target);
|
161
168
|
}
|
162
169
|
|
163
170
|
ReturnStatement* NewReturnStatement(Expression* expr) {
|
@@ -172,16 +179,22 @@ class AstFactory : public core::Space<2> {
|
|
172
179
|
return new (this) SwitchStatement(expr, this);
|
173
180
|
}
|
174
181
|
|
175
|
-
CaseClause* NewCaseClause() {
|
176
|
-
return new (this) CaseClause(this);
|
182
|
+
CaseClause* NewCaseClause(bool is_default, Expression* expr) {
|
183
|
+
return new (this) CaseClause(is_default, expr, this);
|
177
184
|
}
|
178
185
|
|
179
186
|
ThrowStatement* NewThrowStatement(Expression* expr) {
|
180
187
|
return new (this) ThrowStatement(expr);
|
181
188
|
}
|
182
189
|
|
183
|
-
TryStatement* NewTryStatement(Block*
|
184
|
-
|
190
|
+
TryStatement* NewTryStatement(Block* try_block,
|
191
|
+
Identifier* catch_name,
|
192
|
+
Block* catch_block,
|
193
|
+
Block* finally_block) {
|
194
|
+
return new (this) TryStatement(try_block,
|
195
|
+
catch_name,
|
196
|
+
catch_block,
|
197
|
+
finally_block);
|
185
198
|
}
|
186
199
|
|
187
200
|
LabelledStatement* NewLabelledStatement(Expression* expr, Statement* stmt) {
|
data/ext/iv/phonic/phonic.cc
CHANGED
@@ -14,54 +14,7 @@ void Init_phonic() {
|
|
14
14
|
VALUE mIVPhonic = rb_define_module_under(mIV, "Phonic");
|
15
15
|
rb_define_module_function(mIVPhonic, "parse",
|
16
16
|
RBFUNC(&iv::phonic::RParser::Parse), 1);
|
17
|
-
|
18
17
|
iv::phonic::RParser::Init(mIVPhonic);
|
19
|
-
|
20
|
-
VALUE cNode = rb_define_class_under(mIVPhonic, "Node", rb_cObject);
|
21
|
-
VALUE cExpr = rb_define_class_under(mIVPhonic, "Expression", cNode);
|
22
|
-
VALUE cStmt = rb_define_class_under(mIVPhonic, "Statement", cNode);
|
23
|
-
|
24
|
-
// Expressions
|
25
|
-
rb_define_class_under(mIVPhonic, "Identifier", cExpr);
|
26
|
-
rb_define_class_under(mIVPhonic, "StringLiteral", cExpr);
|
27
|
-
rb_define_class_under(mIVPhonic, "NumberLiteral", cExpr);
|
28
|
-
rb_define_class_under(mIVPhonic, "RegExpLiteral", cExpr);
|
29
|
-
rb_define_class_under(mIVPhonic, "FunctionLiteral", cExpr);
|
30
|
-
rb_define_class_under(mIVPhonic, "ArrayLiteral", cExpr);
|
31
|
-
rb_define_class_under(mIVPhonic, "ObjectLiteral", cExpr);
|
32
|
-
rb_define_class_under(mIVPhonic, "NullLiteral", cExpr);
|
33
|
-
rb_define_class_under(mIVPhonic, "ThisLiteral", cExpr);
|
34
|
-
rb_define_class_under(mIVPhonic, "Undefined", cExpr);
|
35
|
-
rb_define_class_under(mIVPhonic, "TrueLiteral", cExpr);
|
36
|
-
rb_define_class_under(mIVPhonic, "FalseLiteral", cExpr);
|
37
|
-
rb_define_class_under(mIVPhonic, "ConditionalExpression", cExpr);
|
38
|
-
rb_define_class_under(mIVPhonic, "PostfixExpression", cExpr);
|
39
|
-
rb_define_class_under(mIVPhonic, "BinaryOperation", cExpr);
|
40
|
-
rb_define_class_under(mIVPhonic, "UnaryOperation", cExpr);
|
41
|
-
rb_define_class_under(mIVPhonic, "Assignment", cExpr);
|
42
|
-
rb_define_class_under(mIVPhonic, "FunctionCall", cExpr);
|
43
|
-
rb_define_class_under(mIVPhonic, "ConstructorCall", cExpr);
|
44
|
-
rb_define_class_under(mIVPhonic, "IndexAccess", cExpr);
|
45
|
-
rb_define_class_under(mIVPhonic, "IdentifierAccess", cExpr);
|
46
|
-
|
47
|
-
// Statements
|
48
|
-
rb_define_class_under(mIVPhonic, "Block", cStmt);
|
49
|
-
rb_define_class_under(mIVPhonic, "VariableStatement", cStmt);
|
50
|
-
rb_define_class_under(mIVPhonic, "IfStatement", cStmt);
|
51
|
-
rb_define_class_under(mIVPhonic, "DoWhileStatement", cStmt);
|
52
|
-
rb_define_class_under(mIVPhonic, "WhileStatement", cStmt);
|
53
|
-
rb_define_class_under(mIVPhonic, "ForInStatement", cStmt);
|
54
|
-
rb_define_class_under(mIVPhonic, "ForStatement", cStmt);
|
55
|
-
rb_define_class_under(mIVPhonic, "ExpressionStatement", cStmt);
|
56
|
-
rb_define_class_under(mIVPhonic, "ContinueStatement", cStmt);
|
57
|
-
rb_define_class_under(mIVPhonic, "ReturnStatement", cStmt);
|
58
|
-
rb_define_class_under(mIVPhonic, "BreakStatement", cStmt);
|
59
|
-
rb_define_class_under(mIVPhonic, "WithStatement", cStmt);
|
60
|
-
rb_define_class_under(mIVPhonic, "SwitchStatement", cStmt);
|
61
|
-
rb_define_class_under(mIVPhonic, "ThrowStatement", cStmt);
|
62
|
-
rb_define_class_under(mIVPhonic, "TryStatement", cStmt);
|
63
|
-
rb_define_class_under(mIVPhonic, "LabelledStatement", cStmt);
|
64
|
-
rb_define_class_under(mIVPhonic, "DebuggerStatement", cStmt);
|
65
18
|
}
|
66
19
|
|
67
20
|
}
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Constellation
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-10 00:00:00 +09:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|