Skip to content

Commit

Permalink
BooInBoo=>MetaBoo
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.codehaus.org/boo/trunk@480 2c1201b4-01cd-e047-a400-b836ae1fbc61
  • Loading branch information
bamboo committed Apr 29, 2004
1 parent d3ee52b commit 7c5288d
Show file tree
Hide file tree
Showing 19 changed files with 215 additions and 33 deletions.
2 changes: 1 addition & 1 deletion examples/asp.net/PrettyPrinter.aspx.boo
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class PrettyPrinter(BooPrinterVisitor):
override def WriteOperator(text as string):
_writer.Write("<span class='operator'>${Server.HtmlEncode(text)}</span>")

override def OnStringFormattingExpression(node as StringFormattingExpression):
override def OnExpressionInterpolationExpression(node as ExpressionInterpolationExpression):
_writer.Write("<span class='string'>")
super(node)
_writer.Write("</span>")
Expand Down
62 changes: 32 additions & 30 deletions extras/boox/src/BooEditor.boo
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,24 @@ import Boo.Lang.Compiler.Pipeline.Definitions
import Boo.AntlrParser
import Boo.Lang.Compiler.Ast

class ConsoleCapture(IDisposable):
_console = StringWriter()
_old

def constructor():
_old = Console.Out
Console.SetOut(_console)

override def ToString():
return _console.ToString()

def Dispose():
Console.SetOut(_old)

class BooEditor(Content):

_editor as TextEditorControl
_main as MainForm
_oldStdOut as TextWriter
_compileOutput as TextWriter

[getter(FileName)]
_fname as string
Expand Down Expand Up @@ -142,35 +154,25 @@ class BooEditor(Content):
compiler.Parameters.References.Add(typeof(Form).Assembly)
compiler.Parameters.References.Add(typeof(System.Drawing.Size).Assembly)

RedirectConsoleOut()

started = date.Now
result = compiler.Run()
finished = date.Now
_main.StatusText = "Compilation finished in ${finished-started} with ${len(result.Errors)} error(s)."

ClearTaskList()
if len(result.Errors):
UpdateTaskList(result.Errors)
else:
try:
result.GeneratedAssemblyEntryPoint.Invoke(null, (null,))
except x:
print(x)

RestoreConsoleOut()
UpdateDebugOutputPane()

def RedirectConsoleOut():
_oldStdOut = Console.Out
_compileOutput = StringWriter()
Console.SetOut(_compileOutput)
using console=ConsoleCapture():

started = date.Now
result = compiler.Run()
finished = date.Now
_main.StatusText = "Compilation finished in ${finished-started} with ${len(result.Errors)} error(s)."

def RestoreConsoleOut():
Console.SetOut(_oldStdOut)

def UpdateDebugOutputPane():
text = _compileOutput.ToString()
ClearTaskList()
if len(result.Errors):
UpdateTaskList(result.Errors)
else:
try:
result.GeneratedAssemblyEntryPoint.Invoke(null, (null,))
except x:
print(x)

UpdateOutputPane(console.ToString())

def UpdateOutputPane(text as string):
_main.OutputPane.SetBuildText(text)
_main.ShowOutputPane() if len(text)

Expand Down
34 changes: 34 additions & 0 deletions meta/BooInBoo.Tests/CompilerFixture.boo
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace BooInBoo.Tests

import System.IO
import NUnit.Framework
import BooInBoo
import BooInBoo.Pipelines
import BooInBoo.PipelineSteps

abstract class AbstractCompilerFixture:
virtual def GetTestCasePath():
return Path.GetDirectoryName(typeof(AbstractCompilerFixture).Assembly.Location)

virtual def CreatePipeline() as CompilerPipeline:
pass

[TestFixture]
class CompilerFixture(AbstractCompilerFixture):
override def CreatePipeline():
pipeline = CompileToFilePipeline()
pipeline.Add(Run())
return pipeline

override def GetTestCasePath():
return Path.Combine(super(), "compilation")

[TestFixture]
class BooInBooSemanticsTestCase(AbstractCompilerFixture):
override def CreatePipeline():
pipeline = CompilePipeline()
pipeline.Add(PrintBoo())
return pipeline

override def GetTestCasePath():
return Path.Combine(super(), "semantics")
52 changes: 52 additions & 0 deletions meta/BooInBoo/Compiler.boo
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
namespace BooInBoo

import System

interface ICompilerComponent(System.IDisposable):
def Initialize(context as CompilerContext)

interface ICompilerPipelineStep(ICompilerComponent):
def Run()

interface ICompilerInput:
Name as string:
get

def Open() as System.IO.TextReader

interface ICompilerResource:
Name as string:
get
Description as string:
get
def WriteResources(writer as System.Resources.IResourceWriter)

class AbstractCompilerPipelineStep(ICompilerPipelineStep):
_context as CompilerContext

def Initialize(context as CompilerContext):
_context = context

def Dispose():
_context = null

CompileUnit:
get:
return _context.CompileUnit

class CompilerPipeline:
_steps = []

def Add([required] step as ICompilerPipelineStep):
pass

virtual def Initialize():
pass

class CompilerContext:
CompileUnit as Boo.Lang.Compiler.Ast.CompileUnit:
get:
return null

class Compiler:
pass
35 changes: 35 additions & 0 deletions meta/BooInBoo/PipelineSteps/CreateBindings.boo
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace BooInBoo.PipelineSteps

import BooInBoo

enum BindingType:
CompileUnit
Module
Class
Interface
Enum
Callable
Constructor
Method
Field
Property
Namespace

interface IBinding:
ParentNamespace as INamespace:
get
BindingType as BindingType:
get

interface INamespace(IBinding):
def Resolve(name as string) as IBinding

interface INameResolutionService(ICompilerComponent):
def EnterNamespace(ns as INamespace)
def LeaveNamespace()
def Resolve(name as string) as List

class CreateBindings(AbstractCompilerPipelineStep):

override def Run():
pass
10 changes: 10 additions & 0 deletions meta/BooInBoo/PipelineSteps/PrintBoo.boo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace BooInBoo.PipelineSteps

import BooInBoo
import Boo.Lang.Compiler.Ast
import Boo.Lang.Compiler.Ast.Visitors

class PrintBoo(AbstractCompilerPipelineStep):

override def Run():
BooPrinterVisitor(System.Console.Out).Switch(self.CompileUnit)
8 changes: 8 additions & 0 deletions meta/BooInBoo/PipelineSteps/Run.boo
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace BooInBoo.PipelineSteps

import BooInBoo

class Run(AbstractCompilerPipelineStep):

override def Run():
pass
38 changes: 38 additions & 0 deletions meta/BooInBoo/Pipelines/CompileToFile.boo
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace BooInBoo.Pipelines

import BooInBoo

class ParsePipeline(CompilerPipeline):
static _defaultParserStepType = System.Type.GetType("Boo.AntlrParser.BooParsingStep, Boo.AntlrParser", true)

override def Initialize():
Add(_defaultParserStepType())

class CompilePipeline(ParsePipeline):
override def Initialize():
pass
/*
pipeline.Add(IntroduceGlobalNamespaces())
pipeline.Add(IntroduceBindingService())
pipeline.Add(BindNamespaces())
pipeline.Add(IntroduceNameResolutionService())
pipeline.Add(BindAndApplyAttributes())
pipeline.Add(ExpandMacros())
pipeline.Add(IntroduceModuleClasses())
pipeline.Add(NormalizeTypeMembers())
pipeline.Add(NormalizeStatementModifiers())
pipeline.Add(BindTypeDefinitions())
pipeline.Add(BindTypeMembers())
pipeline.Add(CheckTypeMemberDeclarations())
pipeline.Add(PreOptimizeExpressions())
pipeline.Add(IntroduceCallableResolutionService())
pipeline.Add(ProcessMethodBodies())
pipeline.Add(ProcessGenerators()) // for and yield
pipeline.Add(CheckInterfaceImplementations())
pipeline.Add(InjectCasts())
*/

class CompileToFilePipeline(CompilePipeline):

override def Initialize():
pass
4 changes: 4 additions & 0 deletions meta/BooInBoo/Services/NameResolutionService.boo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace BooInBoo.Services

class NameResolutionService:
pass
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions scripts/dumptokens.boo
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ if "/r" in argv:
else:
lexer = BooParser.CreateBooLexer("stdin", reader)
while token=lexer.nextToken():
if token.Type == Token.EOF_TYPE:
break
break if token.Type == Token.EOF_TYPE
print(token)

0 comments on commit 7c5288d

Please sign in to comment.