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
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.
Latest Comments