private static void showExpressions(List <AbstractExpression> expressions) { foreach (var expression in expressions) { if (expression is AssignmentExpression) { Console.WriteLine($"type: {expression.type}"); AssignmentExpression assignmentExpression = (AssignmentExpression)expression; Console.WriteLine("left: "); if (assignmentExpression.identifier != null) { if (assignmentExpression.identifier != null) { Console.WriteLine($"\tidentifier: {assignmentExpression.identifier}"); } else if (assignmentExpression.propertiesExpression != null) { Console.WriteLine($"\ttype - {assignmentExpression.propertiesExpression.type}"); Console.WriteLine($"\tkeyWord: {assignmentExpression.propertiesExpression.keyWord}"); Console.WriteLine($"\tidentifier: {assignmentExpression.propertiesExpression.identifier}"); } } Console.WriteLine("right: "); Expression right = assignmentExpression.Right; showExpression(right); } else if (expression is InitializationExpression) { showInitialization(expression); } else if (expression is DeclarationExpression) { DeclarationExpression declarationExpression = (DeclarationExpression)expression; Console.WriteLine($"type - {declarationExpression.type}"); Console.WriteLine("left"); showInitialization(declarationExpression.initializationExpression, "\t"); Console.WriteLine("right: "); showExpression(declarationExpression.expression); } else if (expression is OperationExpression) { OperationExpression operationExpression = (OperationExpression)expression; Console.WriteLine($"type - {operationExpression.type}"); Console.WriteLine($"identifier - {operationExpression.identifier}"); Console.WriteLine($"method name - {operationExpression.methodName}"); Console.WriteLine("attributes"); foreach (var attr in operationExpression.attributes) { Console.WriteLine($"\tattribute: {attr}"); } } Console.WriteLine(); } }
private DeclarationExpression createDeclExpr(InitializationExpression initExpr, AssignmentExpression assgnExpr) { DeclarationExpression declExpr = new DeclarationExpression(); declExpr.initializationExpression = initExpr; declExpr.expression = assgnExpr.Right; return(declExpr); }
private AbstractExpression parseDeclarationExpression(List <Token> currentTokens, int assignmentIndex) { DeclarationExpression expression = new DeclarationExpression(); List <Token> left = currentTokens.GetRange(0, assignmentIndex); List <Token> right = currentTokens.GetRange(assignmentIndex + 1, currentTokens.Count - assignmentIndex - 1); expression.initializationExpression = (InitializationExpression)parseInitialization(left); expression.expression = (Expression)parseExpression(right); expression.Line = currentTokens[0].Line; return(expression); }
private void TranslateDeclExpression(DeclarationExpression expression) { TranslateInitExpr(expression.initializationExpression); if (expression.expression.Identifier != null) { setIdById(expression.initializationExpression.identifier, expression.expression.Identifier); return; } else if (expression.expression.Str != null) { setStringById(expression.initializationExpression.identifier, expression.expression.Str); } TranlateDefExpr(expression.expression.definitionExpressions, expression.initializationExpression.identifier); }
private void AnalyzeDecExpr(DeclarationExpression expr) { AnalyzeInitializationExpr(expr.initializationExpression); AnalyzeExpr(expr.expression, expr.initializationExpression.keyWord); }