CpS 450 Language Translation Systems

Beyond Compilers

Compiler technology is not just for Creating Compilers

  • Many common applications include built-in macro facilities which often feature full-blown scripting engines

  • Applications that have to read data files with complicated formats use parsers

Adding Scripting Capability to Applications

  • Do your users need to automate certain tasks in your application? Don’t write a custom macro facility; make your application scriptable!

  • Ultimate Example: Microsoft Office/VBA

Don’t Invent Your Own Language

Why invent a language and write a parser when you can use a scripting engine

Java: Scripting API

  • Java Scripting API (https://docs.oracle.com/javase/9/docs/api/javax/script/package-summary.html)

  • Supports: Javascript (built in), Python, Tcl, …

  • Demo: /examples/beyondcompilers/scriptdemo

.NET: Dynamic Language Runtime

  • Overview of DLR

  • IronPython Demo

    1. Create a .NET WPF App
    2. Install IronPython NuGet Package
    3. Initialize engine

      var engine = Python.CreateEngine();
      var scope = engine.CreateScope();             
      
    4. Inject objects into scope of script
      scope.SetVariable("varname", var);
      ScriptSource source = engine.CreateScriptSourceFromString("print(varname)");     
      
    5. Execute script
      source.Execute(scope);
      

A Bit of History

http://www.softwarepreservation.org/projects/FORTRAN/video/FORTRAN-1982.wmv/view

History of Fortran (~10 min) Local: “G:\CpS450\videos\FORTRAN-1982.wmv”