mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-16 16:31:32 +00:00
Preliminary strings
While not well-wrought, it's at least possible now to log some stuff when debugging
This commit is contained in:
@ -741,13 +741,14 @@ export class Parser extends DiagnosticEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
if (tn.skip(Token.CONSTRUCTOR) || tn.skip(Token.IDENTIFIER)) { // order is important
|
||||
var identifier: IdentifierExpression = tn.token == Token.CONSTRUCTOR
|
||||
var isConstructor = tn.skip(Token.CONSTRUCTOR);
|
||||
if (isConstructor || tn.skip(Token.IDENTIFIER)) {
|
||||
var identifier = isConstructor
|
||||
? Node.createConstructorExpression(tn.range())
|
||||
: Node.createIdentifierExpression(tn.readIdentifier(), tn.range());
|
||||
var typeParameters: TypeParameter[] | null;
|
||||
if (tn.skip(Token.LESSTHAN)) {
|
||||
if (identifier.kind == NodeKind.CONSTRUCTOR)
|
||||
if (isConstructor)
|
||||
this.error(DiagnosticCode.Type_parameters_cannot_appear_on_a_constructor_declaration, tn.range()); // recoverable
|
||||
typeParameters = this.parseTypeParameters(tn);
|
||||
if (!typeParameters)
|
||||
@ -755,9 +756,6 @@ export class Parser extends DiagnosticEmitter {
|
||||
} else
|
||||
typeParameters = [];
|
||||
|
||||
if (identifier.kind == NodeKind.CONSTRUCTOR && tn.peek() != Token.OPENPAREN)
|
||||
this.error(DiagnosticCode.Constructor_implementation_is_missing, tn.range());
|
||||
|
||||
// method: '(' Parameters (':' Type)? '{' Statement* '}' ';'?
|
||||
if (tn.skip(Token.OPENPAREN)) {
|
||||
var parameters = this.parseParameters(tn);
|
||||
@ -802,6 +800,12 @@ export class Parser extends DiagnosticEmitter {
|
||||
tn.skip(Token.SEMICOLON);
|
||||
return retMethod;
|
||||
|
||||
} else if (isConstructor) {
|
||||
this.error(DiagnosticCode.Constructor_implementation_is_missing, identifier.range());
|
||||
|
||||
} else if (isGetter || isSetter) {
|
||||
this.error(DiagnosticCode.Function_implementation_is_missing_or_not_immediately_following_the_declaration, identifier.range());
|
||||
|
||||
// field: (':' Type)? ('=' Expression)? ';'?
|
||||
} else {
|
||||
var modifier: Modifier | null;
|
||||
|
Reference in New Issue
Block a user