...
This commit is contained in:
@@ -271,19 +271,10 @@ public static class Parser
|
||||
{
|
||||
ExpectSymbol(Symbol.Let);
|
||||
var name = ExpectIdentifier().Value;
|
||||
var type = Optional<NubType>.Empty();
|
||||
if (TryExpectSymbol(Symbol.Colon))
|
||||
{
|
||||
type = ParseType();
|
||||
}
|
||||
|
||||
var value = Optional<ExpressionNode>.Empty();
|
||||
if (TryExpectSymbol(Symbol.Assign))
|
||||
{
|
||||
value = ParseExpression();
|
||||
}
|
||||
|
||||
return new VariableDeclarationNode(GetTokensForNode(startIndex), name, type, value);
|
||||
ExpectSymbol(Symbol.Colon);
|
||||
var type = ParseType();
|
||||
|
||||
return new VariableDeclarationNode(GetTokensForNode(startIndex), name, type);
|
||||
}
|
||||
|
||||
private static StatementNode ParseBreak(int startIndex)
|
||||
@@ -674,6 +665,11 @@ public static class Parser
|
||||
return new NubVoidType();
|
||||
}
|
||||
|
||||
if (name.Value == "string")
|
||||
{
|
||||
return new NubArrayType(NubPrimitiveType.U8);
|
||||
}
|
||||
|
||||
if (NubPrimitiveType.TryParse(name.Value, out var primitiveTypeKind))
|
||||
{
|
||||
return new NubPrimitiveType(primitiveTypeKind.Value);
|
||||
|
||||
Reference in New Issue
Block a user