Exemple #1
0
 static void SerializeElement(IndentingWriter writer,
                              Ast.SyntaxNode element)
 {
     if (element is Ast.TextElement textElement)
     {
         SerializeTextElement(writer, textElement);
     }
     else if (element is Ast.Placeable placeable)
     {
         SerializePlaceable(writer, placeable);
     }
     else
     {
         throw new InvalidOperationException($"Unknown element type {element.GetType()}");
     }
 }
Exemple #2
0
 static void SerializeValue(IndentingWriter writer, Ast.SyntaxNode value)
 {
     if (value is Ast.Pattern pattern)
     {
         SerializePattern(writer, pattern);
     }
     else if (value is Ast.VariantList variantList)
     {
         SerializeVariantList(writer, variantList);
     }
     else
     {
         throw new InvalidOperationException(
                   $"Unknown value type {value.GetType()}");
     }
 }
Exemple #3
0
 static void SerializeVariantKey(IndentingWriter writer,
                                 Ast.SyntaxNode key)
 {
     if (key is Ast.VariantName variantName)
     {
         SerializeVariantName(writer, variantName);
     }
     else if (key is Ast.NumberLiteral numberLiteral)
     {
         SerializeNumberLiteral(writer, numberLiteral);
     }
     else
     {
         throw new InvalidOperationException(
                   $"Unknown variant key type: {key.GetType()}");
     }
 }
Exemple #4
0
 static void SerializeExpression(IndentingWriter writer,
                                 Ast.SyntaxNode expression)
 {
     if (expression is Ast.StringLiteral stringLiteral)
     {
         SerializeStringLiteral(writer, stringLiteral);
     }
     else if (expression is Ast.NumberLiteral numberLiteral)
     {
         SerializeNumberLiteral(writer, numberLiteral);
     }
     else if (expression is Ast.MessageTermReference mtReference)
     {
         SerializeMessageTermReference(writer, mtReference);
     }
     else if (expression is Ast.VariableReference varReference)
     {
         SerializeVariableReference(writer, varReference);
     }
     else if (expression is Ast.AttributeExpression attributeExpression)
     {
         SerializeAttributeExpression(writer, attributeExpression);
     }
     else if (expression is Ast.VariantExpression variantExpression)
     {
         SerializeVariantExpression(writer, variantExpression);
     }
     else if (expression is Ast.CallExpression callExpression)
     {
         SerializeCallExpression(writer, callExpression);
     }
     else if (expression is Ast.SelectExpression selectExpression)
     {
         SerializeSelectExpression(writer, selectExpression);
     }
     else if (expression is Ast.Placeable placeable)
     {
         SerializePlaceable(writer, placeable);
     }
     else
     {
         throw new InvalidOperationException(
                   $"Unknown expression type: {expression.GetType()}");
     }
 }