Skip to content

Commit e65586a

Browse files
committed
..
1 parent 4051984 commit e65586a

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'package:parsejs/parsejs.dart';
88
99
void main() {
1010
new File('test.js').readAsString().then((String code) {
11-
Program ast = parse(code, filename: 'test.js')
11+
Program ast = parsejs(code, filename: 'test.js')
1212
// Use the AST for something
1313
})
1414
}

lib/src/ast.dart

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ part 'ast_visitor.dart';
99
abstract class Node {
1010
/// The parent of this node, or null if this is the [Program] node.
1111
///
12-
/// If you transform the AST in any way, it is your own responsibility to update pointer pointers accordingly.
12+
/// If you transform the AST in any way, it is your own responsibility to update parent pointers accordingly.
1313
Node parent;
1414

1515
/// Source-code offset.
@@ -149,8 +149,6 @@ class Name extends Node {
149149
visitBy(Visitor v) => v.visitName(this);
150150
}
151151

152-
///// STATEMENTS /////
153-
154152
/// Superclass for all nodes that are statements.
155153
abstract class Statement extends Node {}
156154

@@ -547,10 +545,17 @@ class ObjectExpression extends Expression {
547545
}
548546

549547
/// Property initializer `[key]: [value]`, or getter `get [key] [value]`, or setter `set [key] [value]`.
548+
///
549+
/// For getters and setters, [value] is a [FunctionNode], otherwise it is an [Expression].
550550
class Property extends Node {
551-
Node key; // Literal or Name
552-
Node value; // Will be FunctionNode with no name for getters and setters
553-
String kind; // May be: init, get, set
551+
/// Literal or Name indicating the name of the property. Use [nameString] to get the name as a string.
552+
Node key;
553+
554+
/// A [FunctionNode] (for getters and setters) or an [Expression] (for ordinary properties).
555+
Node value;
556+
557+
/// May be "init", "get", or "set".
558+
String kind;
554559

555560
Property(this.key, this.value, [this.kind = 'init']);
556561
Property.getter(this.key, FunctionExpression this.value) : kind = 'get';

0 commit comments

Comments
 (0)