notify method
Implementation
TagserResult? notify(NotifyMessage msg, TagserContext context) {
switch (msg.type) {
case notifyTagNameResult:
final String? tagName = msg.value?.toString();
_tag = Tag(
name: tagName ?? '',
type: typeTag,
symbol: context.symbol ?? 0,
line: context.line);
return TagserResult(
message: ProcessMessage(
charCode: msg.charCode,
),
);
/*
return TagserResult(
err: TagserError(
code: ERROR_EMPTY_TAG_NAME,
text: getError(ERROR_EMPTY_TAG_NAME, null),
),
);
*/
case notifyAttrResult:
_tag!.addAttr(msg.value);
return TagserResult(
message: ProcessMessage(
charCode: msg.charCode,
),
);
case notifyCloseBracketFound:
return TagserResult(
pop: true,
message: NotifyMessage(
type: notifyTagResult,
value: _tag,
),
);
case notifyCloseTag:
if (msg.value != null && msg.value is List) {
for (final t in (msg.value as List)) {
_tag!.addChild(t);
}
}
return TagserResult(
pop: true,
message: NotifyMessage(
type: notifyTagResult,
value: _tag,
),
);
default:
return null;
}
}