GithubHelp home page GithubHelp logo

coca's People

Contributors

darkf avatar devyn avatar dsamarin avatar eligrey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coca's Issues

Wide string literals and character constants need to be recognized

If a string literal or character constant is preceded by the capital letter L, as in L"Hello, world" and L'a', then they need to be recognized as such. In that case, read_string_literal or read_character_constant should have true be passed as its first (and only) argument.

Trigraph/digraph sequences are not supported

Tokenizer.prototype.nextch should recognize trigraph sequences and instead return the correct replacement.

Before any other processing takes place, each occurrence of one of the following
sequences of three characters (called trigraph sequences12)) is replaced with the
corresponding single character.

??=  #
??(   [
??/   \
??)   ]
??'   ^
??<   {
??!   |
??>   }
??-   ~

Digraphs are easier to add since the punctuators are constructed automatically as a trie structure and can be added with the add() method of Token.punctuators.

Inefficient peekch() and lookahead()

The save() and restore() method of keeping track of the cursor is very inefficient. It may be best to implement unget-type functions. In the end the tokenizer might have to be re-thought out to be more efficient, but this is low priority.

UTF-16 surrogate pairs are treated as separate characters

To fix: Tokenizer.prototype.nextch should recognize a high surrogate, calculate the character from the character (assuming its a low surrogate), and advance the cursor as required.

To get the character code of a surrogate pair: ((hi - 0xD800) * 0x400) + (lo - 0xDC00) + 0x10000

Tokenizer.prototype.codes_to_string needs to do UTF-16 encoding

Some of the Unicode code points will be larger than 0xFFFF which String.fromCharCode can't handle. The array must first be traversed and characters larger than 0xFFFF need to be broken up into 2 elements with this formula:

var hi, lo;
hi = Math.floor((ch - 0x10000) / 0x400) + 0xD800;
lo = ((ch - 0x10000) % 0x400) + 0xDC00;

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.