Skip to content

Files

Latest commit

fe42f4c · Mar 14, 2016

History

History

fib

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Mar 14, 2016
Mar 11, 2016
Mar 11, 2016
Mar 11, 2016
Mar 11, 2016
Mar 11, 2016
Mar 11, 2016
Mar 14, 2016

Example 1: Fibonacci

Pseudo AST

Generated from original.py using pseudo-python

It demonstrates

  • Type inference

  • Native standard library use: Pseudo uses the target language standard library print function

  • Syntax translation

  • Even if you are making a cat-based psychosomatic compiler targeting elvish slangs, you have a fibonacci example

The next two examples: football and verbal_expressions are way more interesting

Commands: (assuming you're in examples/fib)

  • python

    translate to py with

    # from python source
    > pseudo-python original.py fib.py
    #or from ast
    > pseudo fib.pseudo.yaml py

    and run with

    > python fib.py
    
  • javascript

    translate to js with

    # from python source
    > pseudo-python original.py fib.js
    #or from ast
    > pseudo fib.pseudo.yaml js

    and run with

    > node fib.js
  • ruby

    translate to ruby with

    # from python source
    > pseudo-python original.py fib.rb
    #or from ast
    > pseudo fib.pseudo.yaml rb

    and run with

    > ruby fib.rb
  • c#

    translate to c# with

    # from python source
    > pseudo-python original.py fib.cs
    #or from ast
    > pseudo fib.pseudo.yaml csharp

    and run with

    > mcs fib.cs # or an equivalent command compiling cs files
    > ./fib.exe
  • go

    translate to go with

    # from python source
    > pseudo-python original.py fib.go
    #or from ast
    > pseudo fib.pseudo.yaml go

    and run

    > go run fib.go