Skip to content

Commit 4051984

Browse files
committed
..
1 parent 81be2f3 commit 4051984

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/src/ast.dart

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,7 @@ class UpdateExpression extends Expression {
677677
visitBy(Visitor v) => v.visitUpdateExpression(this);
678678
}
679679

680+
/// Expression of form: `[condition] ? [then] : [otherwise]`.
680681
class ConditionalExpression extends Expression {
681682
Expression condition;
682683
Expression then;
@@ -695,6 +696,7 @@ class ConditionalExpression extends Expression {
695696
visitBy(Visitor v) => v.visitConditional(this);
696697
}
697698

699+
/// Expression of form: `[callee](..[arguments]..)` or `new [callee](..[arguments]..)`.
698700
class CallExpression extends Expression {
699701
bool isNew;
700702
Expression callee;
@@ -713,6 +715,7 @@ class CallExpression extends Expression {
713715
visitBy(Visitor v) => v.visitCall(this);
714716
}
715717

718+
/// Expression of form: `[object].[property].`
716719
class MemberExpression extends Expression {
717720
Expression object;
718721
Name property;
@@ -729,6 +732,7 @@ class MemberExpression extends Expression {
729732
visitBy(Visitor v) => v.visitMember(this);
730733
}
731734

735+
/// Expression of form: `[object][[property]]`.
732736
class IndexExpression extends Expression {
733737
Expression object;
734738
Expression property;
@@ -746,6 +750,7 @@ class IndexExpression extends Expression {
746750
}
747751

748752
/// A [Name] that is used as an expression.
753+
///
749754
/// Note that "undefined", "NaN", and "Infinity" are name expressions, and not literals and one might expect.
750755
class NameExpression extends Expression {
751756
Name name;
@@ -759,8 +764,14 @@ class NameExpression extends Expression {
759764
visitBy(Visitor v) => v.visitNameExpression(this);
760765
}
761766

767+
/// A literal string, number, boolean or null.
768+
///
769+
/// Note that "undefined", "NaN", and "Infinity" are [NameExpression]s, and not literals and one might expect.
762770
class LiteralExpression extends Expression {
771+
/// A string, number, boolean, or null value, indicating the value of the literal.
763772
dynamic value;
773+
774+
/// The verbatim source-code representation of the literal.
764775
String raw;
765776

766777
LiteralExpression(this.value, [this.raw]);
@@ -784,8 +795,10 @@ class LiteralExpression extends Expression {
784795
visitBy(Visitor v) => v.visitLiteral(this);
785796
}
786797

798+
/// A regular expression literal.
787799
class RegexpExpression extends Expression {
788-
String regexp; // Includes slashes and flags and everything (TODO: separate into regexp and flags)
800+
/// The entire literal, including slashes and flags.
801+
String regexp; // TODO: separate into regexp and flags
789802

790803
RegexpExpression(this.regexp);
791804

lib/src/ast_visitor.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
part of ast;
22

3-
/// Visitor interface for AST nodes. See [BaseVisitor] and [RecursiveVisitor].
3+
/// Visitor interface for AST nodes.
4+
///
5+
/// Also see [BaseVisitor] and [RecursiveVisitor].
46
abstract class Visitor<T> {
7+
/// Shorthand for `node.visitBy(this)`.
58
T visit(Node node) => node.visitBy(this);
69

710
T visitPrograms(Programs node);
@@ -113,10 +116,12 @@ class BaseVisitor<T> implements Visitor<T> {
113116
/// the children of the given node, otherwise that subtree will not be traversed.
114117
///
115118
/// For example:
119+
///
116120
/// visitWhile(While node) {
117121
/// print('Found while loop on line ${node.line}');
118122
/// node.forEach(visit); // visit children
119123
/// }
124+
///
120125
/// Without the call to `forEach`, a while loop nested in another while loop would
121126
/// not be found.
122127
class RecursiveVisitor<T> extends BaseVisitor<T> {

0 commit comments

Comments
 (0)