...
This commit is contained in:
@@ -28,6 +28,7 @@ public sealed class Parser
|
||||
var startIndex = _tokenIndex;
|
||||
|
||||
var exported = TryExpectSymbol(Symbol.Export);
|
||||
var packed = TryExpectSymbol(Symbol.Packed);
|
||||
|
||||
if (TryExpectSymbol(Symbol.Extern))
|
||||
{
|
||||
@@ -43,7 +44,7 @@ public sealed class Parser
|
||||
Symbol.Module => ParseModule(startIndex),
|
||||
Symbol.Import => ParseImport(startIndex),
|
||||
Symbol.Func => ParseFunc(startIndex, exported, null),
|
||||
Symbol.Struct => ParseStruct(startIndex, exported),
|
||||
Symbol.Struct => ParseStruct(startIndex, exported, packed),
|
||||
Symbol.Enum => ParseEnum(startIndex, exported),
|
||||
_ => throw new CompileException(Diagnostic
|
||||
.Error($"Expected 'func', 'struct', 'enum', 'import' or 'module' but found '{keyword.Symbol}'")
|
||||
@@ -126,7 +127,7 @@ public sealed class Parser
|
||||
return new FuncSyntax(GetTokens(startIndex), prototype, body);
|
||||
}
|
||||
|
||||
private StructSyntax ParseStruct(int startIndex, bool exported)
|
||||
private StructSyntax ParseStruct(int startIndex, bool exported, bool packed)
|
||||
{
|
||||
var name = ExpectIdentifier();
|
||||
|
||||
@@ -152,7 +153,7 @@ public sealed class Parser
|
||||
fields.Add(new StructFieldSyntax(GetTokens(memberStartIndex), fieldName, fieldType, fieldValue));
|
||||
}
|
||||
|
||||
return new StructSyntax(GetTokens(startIndex), name, exported, fields);
|
||||
return new StructSyntax(GetTokens(startIndex), name, exported, packed, fields);
|
||||
}
|
||||
|
||||
private EnumSyntax ParseEnum(int startIndex, bool exported)
|
||||
@@ -650,7 +651,7 @@ public sealed class Parser
|
||||
var startIndex = _tokenIndex;
|
||||
if (TryExpectIdentifier(out var name))
|
||||
{
|
||||
if (name.Value[0] == 'u' && int.TryParse(name.Value[1..], out var size))
|
||||
if (name.Value[0] == 'u' && ulong.TryParse(name.Value[1..], out var size))
|
||||
{
|
||||
if (size is not 8 and not 16 and not 32 and not 64)
|
||||
{
|
||||
@@ -664,7 +665,7 @@ public sealed class Parser
|
||||
return new IntTypeSyntax(GetTokens(startIndex), false, size);
|
||||
}
|
||||
|
||||
if (name.Value[0] == 'i' && int.TryParse(name.Value[1..], out size))
|
||||
if (name.Value[0] == 'i' && ulong.TryParse(name.Value[1..], out size))
|
||||
{
|
||||
if (size is not 8 and not 16 and not 32 and not 64)
|
||||
{
|
||||
@@ -678,7 +679,7 @@ public sealed class Parser
|
||||
return new IntTypeSyntax(GetTokens(startIndex), true, size);
|
||||
}
|
||||
|
||||
if (name.Value[0] == 'f' && int.TryParse(name.Value[1..], out size))
|
||||
if (name.Value[0] == 'f' && ulong.TryParse(name.Value[1..], out size))
|
||||
{
|
||||
if (size is not 32 and not 64)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user