Latest Replies
Saturday
Jul052008

How to peek inside Boo compiler - part 2

Here's even shorter way of getting to see the Boo compiler in action with details:

  • Get yourself latest SharpDevelop (15MB)
  • Create new Boo project
  • Paste the code below and hit F5. It will print AST in XML to the console

Here's the code

import System
import Boo.Lang.Compiler.IO
import Boo.Lang.Compiler.Pipelines
import Boo.Lang.Compiler

script = """abstract class BaseWorkflow[of X]:
  abstract def Process(record as X):
    pass

class MyWorkflow(BaseWorkflow[of int]):
  def Process(record as int):
    print record"""

booC = BooCompiler()
booC.Parameters.Input.Add(StringInput("script", script))
booC.Parameters.Pipeline = ParseAndPrintXml() 
booC.Parameters.Ducky = true 

context = booC.Run()

if context.GeneratedAssembly is null:
  print join(e for e in context.Errors, "\n")

print "Press any key to continue . . . "
Console.ReadKey(true)

It seems trivial so now, but this little snippet could've saved me a couple of hours this morning while I've been trying to implement custom DSL workflow around a generic base class.

« Implementing ORM-independent Linq queries | Main | How to peek inside the compiler pipeline of Boo »

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>