File tree 1 file changed +21
-2
lines changed
1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -34,12 +34,31 @@ SPEG_actions.prototype.parsing_body = function(node) {
34
34
35
35
SPEG_actions . prototype . parsing_rule = function ( node ) {
36
36
var rule = node . children [ 4 ] ;
37
+ var ruleName = node . children [ 0 ] . match ;
37
38
return {
38
- name : node . children [ 0 ] . match ,
39
+ name : ruleName ,
39
40
parser : function ( state ) {
41
+ var start = state . position ;
40
42
var ast = rule ( state ) ;
41
43
if ( ast ) {
42
- ast . rule = node . children [ 0 ] . match ;
44
+ ast . rule = ruleName ;
45
+ if ( ! state . succesfullRules ) {
46
+ state . succesfullRules = [ ] ;
47
+ }
48
+ state . succesfullRules . push ( {
49
+ rule : ast . rule ,
50
+ match : ast . match ,
51
+ start_position : ast . start_position ,
52
+ end_position : ast . end_position
53
+ } ) ;
54
+ } else {
55
+ if ( ! state . failedRules ) {
56
+ state . failedRules = [ ] ;
57
+ }
58
+ state . failedRules . push ( {
59
+ rule : ruleName ,
60
+ start_position : start
61
+ } ) ;
43
62
}
44
63
return ast ;
45
64
}
You can’t perform that action at this time.
0 commit comments