Skip to content

Latest commit

 

History

History
105 lines (73 loc) · 2.42 KB

README.md

File metadata and controls

105 lines (73 loc) · 2.42 KB

Example 3: Verbal expressions

Pseudo AST

Generated from original.py using pseudo-python

That's a simple library similar to VerbalExpressions

It defines a DSL for more readable definition of regular expressions and uses it with the example from VerbalExpressions README

It demonstrates

  • suitability for writing/porting little libraries and DSL-s

  • native standard library use: Pseudo uses the target language standard library string/regex methods/functions

  • oop handling: It uses prototypical oop in the js version and class-based code in the other versions

  • string interpolation: pseudo-python recognizes and even checks the types of c-style %d%s formatting strings and it uses an idiomatic interpolation mechanism for each of the target languages

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

  • python

    translate to py with

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

    and run with

    > python verbal_expressions.py
    
  • javascript

    translate to js with

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

    and run with

    > node verbal_expressions.js
  • ruby

    translate to ruby with

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

    and run with

    > ruby verbal_expressions.rb
  • c#

    translate to c# with

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

    and run with

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

    translate to go with

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

    and run

    > go run verbal_expressions.go