mirror of
https://github.com/ZuneDev/ZuneUIXTools.git
synced 2026-07-27 13:11:59 -07:00
Support generic types
This commit is contained in:
@@ -72,6 +72,33 @@ public static partial class Lexer
|
||||
typeName = typePrefixResult.Value;
|
||||
}
|
||||
|
||||
// Capture generic types
|
||||
var genericTypeStartPosition = input.Position;
|
||||
var genericTypeMarkerResult = Parse.Char('`')(input);
|
||||
input = genericTypeMarkerResult.Remainder;
|
||||
if (genericTypeMarkerResult.WasSuccessful)
|
||||
{
|
||||
var genericTypeParameterCountResult = Parse.Number(input);
|
||||
input = genericTypeParameterCountResult.Remainder;
|
||||
if (!genericTypeParameterCountResult.WasSuccessful)
|
||||
return Result.Failure<QualifiedTypeName>(input, "Invalid generic type", ["Expected a type parameter count"]);
|
||||
|
||||
var genericTypeParametersOpenBrace = Parse.Char('[')(input);
|
||||
input = genericTypeParametersOpenBrace.Remainder;
|
||||
if (genericTypeParametersOpenBrace.WasSuccessful)
|
||||
{
|
||||
var genericTypeParametersResult = Parse.AnyChar.Except(Parse.Chars('.', ']')).AtLeastOnce().Text()
|
||||
.DelimitedBy(Parse.Char('.'))
|
||||
.Until(Parse.Char(']'))(input);
|
||||
input = genericTypeParametersResult.Remainder;
|
||||
if (!genericTypeParametersResult.WasSuccessful)
|
||||
return Result.Failure<QualifiedTypeName>(input, "Invalid generic type", ["Expected type parameters"]);
|
||||
|
||||
var genericTypeEndPosition = input.Position;
|
||||
typeName += input.Source[genericTypeStartPosition..genericTypeEndPosition];
|
||||
}
|
||||
}
|
||||
|
||||
QualifiedTypeName qualifiedName = new(typePrefix, typeName)
|
||||
{
|
||||
Line = line,
|
||||
|
||||
@@ -27,17 +27,20 @@ public class Assembly
|
||||
.export Default 0 UI
|
||||
.export Alt 0 UI
|
||||
|
||||
.import-ns assembly://UIX/Microsoft.Iris as iris
|
||||
.import-type UI
|
||||
.import-type Dictionary
|
||||
.import-ns assembly://UIX/Microsoft.Iris as iris
|
||||
.import-type iris:Command
|
||||
.import-type String
|
||||
.import-type ViewItem
|
||||
.import-type Text
|
||||
.import-type Color
|
||||
.import-type Font
|
||||
.import-type generic:List`1[System.String]
|
||||
.import-mbrs UI{Locals, Content}
|
||||
.import-mbrs Text{Color, Content, Font}
|
||||
.import-mbrs SingletonModelItem`1[ZuneUI.TransportControls]{Instance}
|
||||
.import-mthd List`1[System.Int32].Add(Int32)
|
||||
|
||||
.constant const0 = Color.str(255, 255, 0, 0)
|
||||
.constant const1 = String.str(Howdy from Microsoft.Iris!)
|
||||
@@ -79,7 +82,7 @@ Alt_locl:
|
||||
_output.WriteLine(ast.ToString());
|
||||
|
||||
Assert.NotNull(ast);
|
||||
Assert.Equal(22, ast.Directives.Count());
|
||||
Assert.Equal(25, ast.Directives.Count());
|
||||
Assert.Equal(24, ast.Code.Count());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user