Skip to content

Commit 7e0e278

Browse files
committed
Add generic types for XmlNode and XmlName.
1 parent ee6798f commit 7e0e278

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

lib/xml/grammar.dart

+12-10
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ part of xml;
22

33
/**
44
* XML grammar definition.
5+
* Grammar of nodes ot type [TNode] with names of type [TName].
56
*/
6-
abstract class XmlGrammarDefinition extends GrammarDefinition {
7+
abstract class XmlGrammarDefinition<TNode, TName> extends GrammarDefinition {
78

89
// name patterns
910
static const NAME_START_CHARS =
@@ -35,15 +36,16 @@ abstract class XmlGrammarDefinition extends GrammarDefinition {
3536
static const CLOSE_PROCESSING = '?>';
3637

3738
// parser callbacks
38-
createAttribute(name, value);
39-
createComment(value);
40-
createCDATA(value);
41-
createDoctype(value);
42-
createDocument(Iterable children);
43-
createElement(name, Iterable attributes, Iterable children);
44-
createProcessing(target, value);
45-
createQualified(name);
46-
createText(value);
39+
TNode createAttribute(TName name, String text);
40+
TNode createComment(String text);
41+
TNode createCDATA(String text);
42+
TNode createDoctype(String text);
43+
TNode createDocument(Iterable<TNode> children);
44+
TNode createElement(TName name, Iterable<TNode> attributes,
45+
Iterable<TNode> children);
46+
TNode createProcessing(String target, String text);
47+
TName createQualified(String name);
48+
TNode createText(String text);
4749

4850
// productions
4951
start() => ref(document).end();

lib/xml/parser.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ part of xml;
33
/**
44
* XML parser that defines standard actions to the the XML tree.
55
*/
6-
class XmlParserDefinition extends XmlGrammarDefinition {
6+
class XmlParserDefinition extends XmlGrammarDefinition<XmlNode, XmlName> {
77
@override
88
XmlAttribute createAttribute(XmlName name, String text) =>
99
new XmlAttribute(name, text);

0 commit comments

Comments
 (0)