Giter VIP home page Giter VIP logo

nkcc's Introduction

C compiler

For now, only the C preprocessor is implemented.

Missing in the preprocessor

  • Evaluation of character constant in #if/#elif expression.
  • Wide char and string.
  • Universal Character Set.

Wish

  • Rewrite in C++. Reason? Just want to focus on the compiler logic itself not stuff like hash table, vector, etc.

nkcc's People

Contributors

n0tknowing avatar

nkcc's Issues

Another macro expansion algorithm idea

Haven't tried it yet but it sounds good.

So, instead of traversing the macro_stack to check if a macro is ok to expand or not, there's a cheaper (and probably faster) algorithm that only use bit flag. And that bit flag is for cpp_macro, we can name it CPP_MACRO_EXPANDING.

The changes to the current codebase probably are:

  • Add cpp_macro * to macro_stack.
  • macro_stack_push() and macro_stack_pop() set and clear CPP_MACRO_EXPANDING bit flag, respectively.
  • Delete is_active_macro() and replace its call in expand() to just checking the bit flag after looking up cpp_macro *.
  • Move expand_arg() to expand() after calling collect_args().
  • Add another cpp_token_array to cpp_macro_arg to store expanded tokens.

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.