Skip to content

Commit 794d765

Browse files
committed
implement switch, case, break nodes
1 parent 84ef031 commit 794d765

File tree

5 files changed

+103
-0
lines changed

5 files changed

+103
-0
lines changed

src/ast/break.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*!
2+
* Copyright (C) 2017 Glayzzle (BSD3 License)
3+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
4+
* @url http://glayzzle.com
5+
*/
6+
"use strict";
7+
var Node = require('./node');
8+
var KIND = 'break';
9+
10+
/**
11+
* A break statement
12+
* @constructor Break
13+
* @extends {Node}
14+
*/
15+
var Break = Node.extends(function Break(location) {
16+
Node.apply(this, [KIND, location]);
17+
});
18+
19+
module.exports = Break;

src/ast/case.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*!
2+
* Copyright (C) 2017 Glayzzle (BSD3 License)
3+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
4+
* @url http://glayzzle.com
5+
*/
6+
"use strict";
7+
var Node = require('./node');
8+
var KIND = 'case';
9+
10+
/**
11+
* A switch case statement
12+
* @constructor Case
13+
* @extends {Node}
14+
* @property {Expression|null} test - if null, means that the default case
15+
* @property {Block|null} body
16+
*/
17+
var Case = Node.extends(function Case(test, body, location) {
18+
Node.apply(this, [KIND, location]);
19+
this.test = test;
20+
this.body = body;
21+
});
22+
23+
module.exports = Case;

src/ast/constref.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*!
2+
* Copyright (C) 2017 Glayzzle (BSD3 License)
3+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
4+
* @url http://glayzzle.com
5+
*/
6+
7+
var Expr = require('./expression');
8+
var KIND = 'constref';
9+
10+
/**
11+
* A constant reference
12+
* @constructor ConstRef
13+
* @extends {Expression}
14+
* @property {String|Node} name
15+
*/
16+
var ConstRef = Expr.extends(function ConstRef(identifier, location) {
17+
Expr.apply(this, [KIND, location]);
18+
this.name = identifier;
19+
});
20+
21+
module.exports = ConstRef;

src/ast/continue.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*!
2+
* Copyright (C) 2017 Glayzzle (BSD3 License)
3+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
4+
* @url http://glayzzle.com
5+
*/
6+
"use strict";
7+
var Node = require('./node');
8+
var KIND = 'continue';
9+
10+
/**
11+
* A continue statement
12+
* @constructor Continue
13+
* @extends {Node}
14+
*/
15+
var Continue = Node.extends(function Continue(location) {
16+
Node.apply(this, [KIND, location]);
17+
});
18+
19+
module.exports = Continue;

src/ast/return.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*!
2+
* Copyright (C) 2017 Glayzzle (BSD3 License)
3+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
4+
* @url http://glayzzle.com
5+
*/
6+
"use strict";
7+
var Node = require('./node');
8+
var KIND = 'return';
9+
10+
/**
11+
* A continue statement
12+
* @constructor Return
13+
* @extends {Node}
14+
* @property {Expression|null} expr
15+
*/
16+
var Return = Node.extends(function Return(expr, location) {
17+
Node.apply(this, [KIND, location]);
18+
this.expr = expr;
19+
});
20+
21+
module.exports = Return;

0 commit comments

Comments
 (0)