public override void GenerateCode(Writer.Writer Writer, API api) { Writer.WriteString($"\t\tswitch("); this.expression.GenerateCode(Writer, api); Writer.WriteString($") {{\n"); if (this.switchBodyNode != null) { switchBodyNode.GenerateCode(Writer, api); } Writer.WriteString($"\t\t}}\n"); }
public override void GenerateCode(Writer.Writer Writer, API api) { Writer.WriteString("\t\twhile ("); this.expression.GenerateCode(Writer, api); Writer.WriteString(") {\n"); if (this.body != null) { this.body.GenerateCode(Writer, api); } Writer.WriteString("\t\t}\n"); }
public void GenerateCode(Writer.Writer Writer, API api) { if (this.caseType == TokenType.RW_CASE) { Writer.WriteString("\t\t\tcase "); this.expression.GenerateCode(Writer, api); Writer.WriteString(" :\n"); } else if (caseType == TokenType.RW_DEFAULT) { Writer.WriteString("\t\t\tdefault:"); } }
public override void GenerateCode(Writer.Writer Writer, API api) { Writer.WriteString($"\t\tif( "); this.expression.GenerateCode(Writer, api); Writer.WriteString($") {{\n "); if (this.statements != null) { this.statements.GenerateCode(Writer, api); } Writer.WriteString($"\t\t}}\n\t\telse {{\n"); if (this.elseBock != null) { elseBock.GenerateCode(Writer, api); } Writer.WriteString($"\t\t}}\n "); }
public override void GenerateCode(Writer.Writer Writer, API api) { foreach (var field in localVariables) { var _field = field.identifier.ToString(); Writer.WriteString($"\t\tlet {_field}"); if (field.assigner != null) { Writer.WriteString(" = "); field.assigner.GenerateCode(Writer, api); } Writer.WriteString(";\n"); } }
public override void GenerateCode(Writer.Writer Writer, API api) { Writer.WriteString($"\t\tfor ({identifier} of "); expression.GenerateCode(Writer, api); Writer.WriteStringLine(") {"); this.body.GenerateCode(Writer, api); Writer.WriteStringLine("\t\t}"); }
public override void GenerateCode(Writer.Writer Writer, API api) { primary.GenerateCode(Writer, api); if (nextExpression != null) { Writer.WriteString("."); nextExpression.GenerateCode(Writer, api); } }
public override void GenerateCode(Writer.Writer Writer, API api) { Writer.WriteStringLine($"\t\tfor ("); if (this.Initializer != null) { this.Initializer.GenerateCode(Writer, api); } Writer.WriteString(";"); if (this.expression != null) { expression.GenerateCode(Writer, api); } Writer.WriteString(";"); Writer.WriteStringLine(") {"); if (this.StatementBlock != null) { StatementBlock.GenerateCode(Writer, api); } Writer.WriteStringLine("\t\t}"); }
public override void GenerateCode(Writer.Writer Writer, API api) { if (returnType == null) { Console.Write(""); } string fullPath = ""; if (isFirst) { fullPath = api.getFullNameByName(returnType); } if (isVariable && wasFoundStatic) { fullPath += ((this.parentName.Length > 0)?this.parentName + ".":"") + Name; } else if (isVariable && !wasFoundStatic) { fullPath = this.parentName + Name; } if (!isVariable) { if (fullPath.Length > 0) { fullPath += (fullPath[fullPath.Length - 1] == '.')?Name:"." + Name; } else { fullPath += "." + Name; } } // fullPath += Name; Writer.WriteString(fullPath); }
public override void GenerateCode(Writer.Writer Writer, API api) { if (this.generated) { return; } var name = api.getNamespaceForType(this).Identifier.ToString() == "default" ? this.Identifier.ToString() : $"{api.getNamespaceForType(this).Identifier}.{this.Identifier}"; var parentName = "GeneratedNamespace.Object"; if (this.parents.Count != 0) { foreach (var parent in parents) { if (parent.Value is ClassTypeNode) { parent.Value.GenerateCode(Writer, api); parentName = api.getFullName(parent.Value) + "." + parent.Key; } } } Writer.WriteStringLine($"GeneratedNamespace.{name} = class extends {parentName} {{"); foreach (var constructor in Constructors) { var paramNames = api.getParamNames(constructor.parameters); var constructorName = api.buildFixedParams(constructor.parameters); constructorName = constructorName.Replace("(", ""); constructorName = constructorName.Replace(")", ""); constructorName = constructorName.Replace(",", "_"); var constName = constructorName == "" ? constructorName : "_" + constructorName; Writer.WriteString($"\t{this.Identifier}{constName}{paramNames} {{\n"); constructor.statementBlock.GenerateCode(Writer, api); Writer.WriteString($"\t}}\n"); } foreach (var method in Methods) { var paramNames = api.getParamNames(method.methodHeaderNode.fixedParams); var methodName = api.buildFixedParams(method.methodHeaderNode.fixedParams); methodName = methodName.Replace("(", ""); methodName = methodName.Replace(")", ""); methodName = methodName.Replace(",", "_"); var methodHheaderName = methodName == "" ? methodName : "_" + methodName; Writer.WriteString($"\t{method.methodHeaderNode.Identifier}{methodHheaderName}{paramNames} {{\n"); if (method.statemetBlock != null) { method.statemetBlock.GenerateCode(Writer, api); } Writer.WriteString($"\t}}\n"); } Writer.WriteString($"\tconstructor(){{\n"); foreach (var field in Fields) { if (field.isStatic) { continue; } var val = "null"; Writer.WriteString($"\t\tthis.{field.identifier} = {val};\n"); } var defaultArgs = @" let argumentos = Array.from(arguments); let argus = argumentos.slice(1); if (argumentos.length >= 1) this[arguments[0]](...argus);"; Writer.WriteString(defaultArgs); Writer.WriteString($"\n\t}}\n"); Writer.WriteString($"}}\n"); foreach (var field in Fields) { if (!field.isStatic) { continue; } var val = "null"; Writer.WriteString($"GeneratedNamespace.{name}.{field.identifier} = {val};\n"); } this.generated = true; }
public virtual void GenerateCode(Writer.Writer Writer, API api) { Writer.WriteString($"{token.lexeme}"); }
public override void GenerateCode(Writer.Writer Writer, API api) { if (!Utils.passAssignExpression(token)) { Writer.WriteString("("); } if (returnType is IntTypeNode) { Writer.WriteString("ToIntPrecision("); } if (leftComparativeType == "CharType" && rightComparativeType == "IntType") { Writer.WriteString("CharToInt("); leftOperand.GenerateCode(Writer, api); Writer.WriteString(")"); Writer.WriteString($" {token.lexeme} "); Writer.WriteString("ToIntPrecision("); rightOperand.GenerateCode(Writer, api); Writer.WriteString(")"); } else if (rightComparativeType == "CharType" && leftComparativeType == "IntType") { Writer.WriteString("ToIntPrecision("); leftOperand.GenerateCode(Writer, api); Writer.WriteString(")"); Writer.WriteString($" {token.lexeme} "); Writer.WriteString("CharToInt("); rightOperand.GenerateCode(Writer, api); Writer.WriteString(")"); } else if (leftComparativeType == "CharType" && rightComparativeType == "CharType") { Writer.WriteString("CharToInt("); leftOperand.GenerateCode(Writer, api); Writer.WriteString(")"); Writer.WriteString($" {token.lexeme} "); Writer.WriteString("CharToInt("); rightOperand.GenerateCode(Writer, api); Writer.WriteString(")"); } else { leftOperand.GenerateCode(Writer, api); Writer.WriteString($" {token.lexeme} "); rightOperand.GenerateCode(Writer, api); } if (returnType is IntTypeNode) { Writer.WriteString(")"); } if (!Utils.passAssignExpression(token)) { Writer.WriteString(")"); } }
public override void GenerateCode(Writer.Writer Writer, API api) { Writer.WriteString(token.lexeme); }
public override void GenerateCode(Writer.Writer Writer, API api) { Writer.WriteString("break"); }
public override void GenerateCode(Writer.Writer Writer, API api) { Writer.WriteString("continue"); }
public override void GenerateCode(Writer.Writer Writer, API api) { Writer.WriteString("\t\treturn"); this.expression.GenerateCode(Writer, api); Writer.WriteString(";"); }