Code Monkey home page Code Monkey logo

c_compiler's Introduction

Development Plan

  1. Write a Jack Tokenizer
  2. Write a basic compilation engine that handles all the features, except for expressions, and array-oriented statements.
  3. Extend the compilation engine to handle expressions.
  4. Extend the compilation engine to handle array-oriented statements.

Token Types

Keyword:

  • class
  • constructor
  • function
  • method
  • field
  • static
  • var
  • int
  • char
  • boolean
  • void
  • true
  • false ...

Symbol:

  • { or }
  • ( or ) etc...

Identifier:

  • String of letters, digits, and underscores that does not start with a digit.

Integer Constant:

  • A sequence of digits from 0 to 9.

String Constant:

  • A sequence of characters not including double quote or newline.

Compiler Logic

Stage 1: Symbol Table

  • Add to each identifier: name, type, kind, and running index.
  • The symbol table is basically a list of hash tables, one for each scope.
    • Each reflects a single scope nested within the next one in the list
    • Compilers look for symbol in the first table in the list, if it fails, it moves to the next table and looks for it (inner scopes outward)
  • We have different types:
    • static: class level
    • field: class level
    • local: subroutine level
    • argument: subroutine level
  • A list of hash tables, each representing a single scope, nested within the next one on the list.
  • We need to define if the identifier is being defined (var declaration) or used.

Repos

https://github.com/timiscoding/JackCompiler/blob/master/SymbolTable.js

c_compiler's People

Contributors

acrucetta avatar

Watchers

 avatar  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.