parseAttribute method
Implementation
Attribute? parseAttribute() {
Identifier? id;
StringLiteral? string;
if ((id = parseIdentifier()) != null) {
// Nothing
} else if (next(TokenType.string)) {
string = StringLiteral(_current, StringLiteral.parseValue(_current));
} else {
return null;
}
Token? equals, nequ;
if (next(TokenType.equals)) {
equals = _current;
} else if (!asDSX && next(TokenType.nequ)) {
nequ = _current;
} else {
return Attribute(id, string, null, null, null);
}
if (!asDSX) {
var value = parseExpression(0);
if (value == null) {
errors.add(JaelError(JaelErrorSeverity.error,
'Missing expression in attribute.', equals?.span ?? nequ!.span));
return null;
}
return Attribute(id, string, equals, nequ, value);
} else {
// Find either a string, or an interpolation.
var value = implicitString();
if (value != null) {
return Attribute(id, string, equals, nequ, value);
}
var interpolation = parseInterpolation();
if (interpolation != null) {
return Attribute(id, string, equals, nequ, interpolation.expression);
}
errors.add(JaelError(JaelErrorSeverity.error,
'Missing expression in attribute.', equals?.span ?? nequ!.span));
return null;
}
}