Git Product home page Git Product logo

3yu's Introduction

3yu (and the Data Processing Counter-language)

a horrible, almost pure-functional esoteric language
made with execution units that are three subunits long

@ stdout~ (
   d message~ S
   : message~ "don't be sad. the time is coming."
   + message~ "\nand then we'll rest."
)

there are two internal phases when running or compiling 3yu code:

  • phase1: analysis

    • parsing
      (into an abstract syntax tree)

    • semantic analysis
      (type checking and argument validation)

  • phase2: interpretation or synthesis

    • phase2a
      tree-walking interpreter

    • phase2b
      zig codegen (only in the stage2 compiler)

an equally horrible roadmap

  • stage1 compiler interpreter
    “the start of the end”

    $ python stage1/3yu.py examples/sum.3yu
    6
    
    • phase1 frontend and phase2a interpreter backend written in python
  • the data processing counter-language
    “thank god it's readable”

    $ python dpc/dpc.py examples/sum.dpc > sum.3yu
    $ python stage1/3yu.py sum.3yu
    6
    
    • transpiler written in python

    • transpiler rewritten in dpc

  • stage2 compiler
    “why is it self-compiled”

    # building the stage2 compiler
    
    # transpile the stage2 compiler into 3yu
    python dpc/dpc.py stage2/3yu.dpc > 3yu.3yu
    
    # self-compile the stage2 compiler into zig using the stage1 interpreter
    cat 3yu.3yu > python stage1/3yu.py 3yu.3yu --compile > 3yu.zig
    
    # compile the generated zig code into an executable
    zig build-exe 3yu.zig
    
    $ cat examples/sum.3yu > ./3yu
    6
    $ cat examples/sum.dpc > ./3yu --compile > 3yu.zig && zig build-exe 3yu.zig
    $ ./sum
    6
    
    • phase1 3yu + dpc frontend and phase2 interpreter + compiler backend written in dpc

the data processing counter-language

an alternative frontend to 3yu

firstly written in python before being rewritten in dpc

sum: func[nums: List[_ Numeric]] -> Numeric = (
   if (len(nums) == 0) (return 0)
   nums[0] + sum(nums[1:])
)

stdout(sum([1, 2, 3]))

will be translated into the following 3yu code with 3yu -t:

d sum~ FL_NN ; sum.dpc:1:1 ;
: sum~ (
   : nums~ $1$
   ? ( ; sum.dpc:2:7 ;
      @ len~ nums~ ; sum.dpc:2:8 ;
      = $0$ 0
   ) ( ; sum.dpc:2: ;
      ` 0 ` ; sum.dpc:2:25 ;
   )
   + ( ; sum.dpc:3:4 ;
      @ index~ nums~ ; sum.dpc:3:8 ;
      @ ! 0
   ) ( ; sum.dpc:3:14 ;
      @ slice~ nums~ ; sum.dpc:3:22 ;
      @ ! 1
      @ ! ( @ len~ nums~ )
      @ ! 1
      @ sum~ $0$
   )
)

@ stdout~ ( ; sum.dpc:6:7 ;
   @ sum~ ( ; sum.dpc:6:8 ;
      d _sum_6_12~ L3I ; sum.dpc:6:12 ;
      + _sum_6_12~ 1
      + $0$ 2
      + $0$ 3
   )
)

3yu's People

Contributors

markjoshwel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.