Index: packages/petitparser/lib/src/petitparser/definition.dart |
diff --git a/petitparser/lib/src/core/definition.dart b/packages/petitparser/lib/src/petitparser/definition.dart |
similarity index 53% |
rename from petitparser/lib/src/core/definition.dart |
rename to packages/petitparser/lib/src/petitparser/definition.dart |
index bd94d69f033ab67e331ca2b3af45579033742553..44b7d72fe0c7a55c2b598a23ff952f1090554517 100644 |
--- a/petitparser/lib/src/core/definition.dart |
+++ b/packages/petitparser/lib/src/petitparser/definition.dart |
@@ -1,62 +1,56 @@ |
part of petitparser; |
-/** |
- * Helper to conveniently define and build complex, recursive grammars using |
- * plain Dart code. |
- * |
- * To create a new grammar definition subclass [GrammarDefinition]. For every |
- * production create a new method returning the primitive parser defining it. |
- * The method called [start] is supposed to return the start production of the |
- * grammar. To refer to a production defined in the same definition use [ref] |
- * with the function reference as the first argument. |
- * |
- * Consider the following example to parse a list of numbers: |
- * |
- * class ListGrammarDefinition extends GrammarDefinition { |
- * start() => ref(list).end(); |
- * list() => ref(element) & char(',') & ref(list) |
- * | ref(element); |
- * element() => digit().plus().flatten(); |
- * } |
- * |
- * Since this is plain Dart code, common refactorings such as renaming a production |
- * updates all references correctly. Also code navigation and code completion |
- * works as expected. |
- * |
- * To attach custom production actions you might want to further subclass your |
- * grammar definition and override overriding the necessary productions defined |
- * in the superclass: |
- * |
- * class ListParserDefinition extends ListGrammarDefinition { |
- * element() => super.element().map((value) => int.parse(value)); |
- * } |
- * |
- * Note that productions can be parametrized. Define such productions with positional |
- * arguments and reference to multiple instances by passing the arguments to [ref]. |
- * |
- * Consider extending the above grammar with a parametrized token production: |
- * |
- * class TokenizedListGrammarDefinition extends GrammarDefinition { |
- * start() => ref(list).end(); |
- * list() => ref(element) & ref(token, char(',')) & ref(list) |
- * | ref(element); |
- * element() => ref(token, digit().plus()); |
- * token(p) => p.token().trim(); |
- * } |
- */ |
+/// Helper to conveniently define and build complex, recursive grammars using |
+/// plain Dart code. |
+/// |
+/// To create a new grammar definition subclass [GrammarDefinition]. For every |
+/// production create a new method returning the primitive parser defining it. |
+/// The method called [start] is supposed to return the start production of the |
+/// grammar. To refer to a production defined in the same definition use [ref] |
+/// with the function reference as the first argument. |
+/// |
+/// Consider the following example to parse a list of numbers: |
+/// |
+/// class ListGrammarDefinition extends GrammarDefinition { |
+/// start() => ref(list).end(); |
+/// list() => ref(element) & char(',') & ref(list) |
+/// | ref(element); |
+/// element() => digit().plus().flatten(); |
+/// } |
+/// |
+/// Since this is plain Dart code, common refactorings such as renaming a production |
+/// updates all references correctly. Also code navigation and code completion |
+/// works as expected. |
+/// |
+/// To attach custom production actions you might want to further subclass your |
+/// grammar definition and override overriding the necessary productions defined |
+/// in the superclass: |
+/// |
+/// class ListParserDefinition extends ListGrammarDefinition { |
+/// element() => super.element().map((value) => int.parse(value)); |
+/// } |
+/// |
+/// Note that productions can be parametrized. Define such productions with positional |
+/// arguments and reference to multiple instances by passing the arguments to [ref]. |
+/// |
+/// Consider extending the above grammar with a parametrized token production: |
+/// |
+/// class TokenizedListGrammarDefinition extends GrammarDefinition { |
+/// start() => ref(list).end(); |
+/// list() => ref(element) & ref(token, char(',')) & ref(list) |
+/// | ref(element); |
+/// element() => ref(token, digit().plus()); |
+/// token(p) => p.token().trim(); |
+/// } |
abstract class GrammarDefinition { |
const GrammarDefinition(); |
- /** |
- * The starting production of this definition. |
- */ |
+ /// The starting production of this definition. |
Parser start(); |
- /** |
- * Returns a parser reference to a production defined by a [function]. |
- * |
- * The optional arguments parametrize the called production. |
- */ |
+ /// Returns a parser reference to a production defined by a [function]. |
+ /// |
+ /// The optional arguments parametrize the called production. |
Parser ref(Function function, [arg1, arg2, arg3, arg4, arg5, arg6]) { |
var arguments = [arg1, arg2, arg3, arg4, arg5, arg6] |
.takeWhile((each) => each != null) |
@@ -64,20 +58,16 @@ abstract class GrammarDefinition { |
return new _Reference(function, arguments); |
} |
- /** |
- * Builds a composite parser from this definition. |
- * |
- * The optional [start] reference specifies a different starting production into |
- * the grammar. The optional [arguments] list parametrizes the called production. |
- */ |
+ /// Builds a composite parser from this definition. |
+ /// |
+ /// The optional [start] reference specifies a different starting production into |
+ /// the grammar. The optional [arguments] list parametrizes the called production. |
Parser build({Function start: null, List arguments: const []}) { |
return _resolve( |
new _Reference(start != null ? start : this.start, arguments)); |
} |
- /** |
- * Internal helper to resolve a complete parser graph. |
- */ |
+ /// Internal helper to resolve a complete parser graph. |
Parser _resolve(_Reference reference) { |
var mapping = new Map(); |
@@ -122,9 +112,7 @@ abstract class GrammarDefinition { |
} |
} |
-/** |
- * A helper to build a parser from a {@link GrammarDefinition}. |
- */ |
+/// A helper to build a parser from a {@link GrammarDefinition}. |
class GrammarParser extends DelegateParser { |
GrammarParser(GrammarDefinition definition) : super(definition.build()); |
} |