Example #1
0
		override public void Run()
		{		
			BooPrinterVisitor visitor = new BooPrinterVisitor(OutputWriter);
			if(Parameters.WhiteSpaceAgnostic)
			{
				visitor.Options |= BooPrinterVisitor.PrintOptions.WSA;
			}
			visitor.Print(CompileUnit);
		}
		public override string GenerateCode(AbstractNode node, string indentation)
		{
			StringBuilder errorBuilder = new StringBuilder();
			ConverterSettings settings = new ConverterSettings("codegeneration.cs");
			string output = null;
			
			Node booNode = (Node)node.AcceptVisitor(new ConvertVisitor(settings), null);
			
			if (settings.Errors.Count > 0) {
				foreach (CompilerError error in settings.Errors) {
					errorBuilder.AppendLine(error.ToString());
				}
			} else {
				if (settings.Warnings.Count > 0) {
					foreach (CompilerWarning warning in settings.Warnings) {
						errorBuilder.AppendLine(warning.ToString());
					}
				}
				booNode.Accept(new RemoveRedundantTypeReferencesVisitor());
				using (StringWriter w = new StringWriter()) {
					BooPrinterVisitor printer = new BooPrinterVisitor(w);
					int indentCount = 0;
					foreach (char c in indentation) {
						if (c == '\t')
							indentCount += 4;
						else
							indentCount += 1;
					}
					indentCount /= 4;
					while (indentCount-- > 0)
						printer.Indent();
					booNode.Accept(printer);
					output = w.ToString();
				}
			}
			if (errorBuilder.Length > 0) {
				MessageService.ShowMessage(errorBuilder.ToString());
			}
			return output;
		}
Example #3
0
 void WriteString(string value)
 {
     BooPrinterVisitor.WriteStringLiteral(value, _writer);
 }
Example #4
0
 override public void OnStringLiteralExpression(StringLiteralExpression node)
 {
     Write("StringLiteralExpression(");
     BooPrinterVisitor.WriteStringLiteral(node.Value, _writer);
     Write(")");
 }