Giter VIP home page Giter VIP logo

expressive's People

Contributors

carlcui avatar

Watchers

 avatar  avatar

expressive's Issues

Improve the way of dealing with escape characters

Currently only a small set of escape characters are allowed and have been parsed manually. It would be helpful to automate this part, as well as transferring them to golang escape characters. (e.g. In parsing, text would be \\n, but the value should be \n.

array implementation

  • fixed size array on stack
  • dynamically allocated array
  • indexing
  • length
  • slicing operations

setup codegen

setup LLVM IR codegen from ast.

  1. Instruction (string. since LLVM IR instruction is not strictly opcode + operand)
  2. Instruction fragments (a fragment of instructions)
  3. macros (predefined sets of instructions)

implement byte and character

Input handler:

  1. Modify NextChar to NextRune
  2. Add NextByte (Still does NextRune, but give error when the rune size is larger than 1)

byte:

  1. size 1 (1 byte)
  2. value as byte
  3. scanByte should scan one byte instead of one whole utf-8 character.

char:

  1. variable size
  2. value as string
  3. scanChar scan one utf-8 character

parser: simpler testing structure

Currently, it costs too much effort writing tests for the parser in these ways:

  1. Setting up mock scanner using token array is tedious
  2. Can only call parser.Parse() (cannot call individual parsing functions)
  3. Testing the results is complicated: need to manually call type assertion and lots of if nesting

Need better way of writing parser tests.

for statement

all except for in, since array implementation is not done yet.

setup basic CLI

compile input file to machine executable

  1. llvm-as: generate llvm bitcode
  2. llvm-link: link bitcode
  3. llc: produce object file
  4. gcc: create executable

Codegen: Explore the necessity of having `InstructionsFragment`

Con:
Consider the following code:

...
frag1 := visitor.removeValueFragment(node.expr)

frag.Append(frag1)

...

Suppose frag1 is InstructionsFragment, and frag is BlocksFragment. If frag already has Term set, then by appending frag1 to frag, essentially the order of execution is altered, unless we create a Block for frag1 and then append the block to frag.

Pro:
Not sure. Currently every fragment is at least a BlocksFragment, even it only contains one block with one instruction. However, llvm will essentially strip out those blocks during optimization phase.

Complete parser for basic operations

Should be able to generate ast for basic operations:

  1. variable declaration/assignment
  2. logic operation
  3. arithmetic
  4. print (can be a built-in printf for debugging purpose)

Update struct creation

Before:

[]*token.Token{
    &token.Token{TokenType: token.IF},
    &token.Token{TokenType: token.LEFT_PAREN}
}

// And

cur.Locator := locator.IndexLocation{scanner.pos}

Now:

[]*token.Token{
    {TokenType: token.IF}, // redundant type
    {TokenType: token.LEFT_PAREN}
}

cur.Locator := locator.IndexLocation{Index: scanner.pos} // disallow unnamed fields

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.