GithubHelp home page GithubHelp logo

krystal's Introduction

krystal

lex&yacc practice

on windows, install them:

on os x, update bison version to 2.4.1 or newer. in terminal,

brew --prefix
brew versions bison
git checkout 804bcf6 Library/Formula/bison.rb
brew unlink bison
brew install bison
bison --version
brew switch bison 2.7.1
bison --version
which bison
ls -lah /usr/local/Cellar/bison/2.7.1/bin/
yacc --version
/usr/local/Cellar/bison/2.7.1/bin/bison --version
/usr/local/Cellar/bison/2.7.1/bin/yacc --version
which yacc
mv /usr/bin/yacc /usr/bin/yacc-2.3
sudo mv /usr/bin/yacc /usr/bin/yacc-2.3
sudo mv /usr/bin/bison /usr/bin/bison-2.3
sudo ln -s /usr/local/Cellar/bison/2.7.1/bin/bison /usr/bin/bison
sudo ln -s /usr/local/Cellar/bison/2.7.1/bin/yacc /usr/bin/yacc
bison --version

http://stackoverflow.com/questions/3987683/homebrew-install-specific-version-of-formula

hash calculation

depends on boost::hash and boost::hash_combine

Packet.getHash

  • hash = hash(packetName)
  • foreach PacketMembers as member:
    • combineHash(hash, member.getHash)
  • return hash

PacketMember.getHash

  • hash = PacketMemberType.getHash
  • combineHash(hash, PacketMemberName.getHash)
  • return hash

PacketMemberType.getHash

  • if PRIMITIVE_TYPE:
    • hash = hash(typeName)
  • else if REFERENCE_TYPE:
    • PacketNode = lookupNodeByName(value)
    • hash = hash(PacketNode.getHash)
  • else if MAP:
    • hash = hash((int)Parser::token::MAP)
    • combineHash(hash, generic1.getHash)
    • combineHash(hash, generic2.getHash)
  • else if LIST:
    • hash = hash((int)Parser::token::LIST)
    • combineHash(hash, generic1.getHash)
  • return hash

PacketMemberName.getHash

  • return hash(name)

example

packet A {
    long A1;
};

packet B {
    short B1;
};

packet C {
    double C1;
    A C2;
    map<int, A> C3;
    list<B> C4;
};

assume that A + B means hash_combine(hash("A"), hash("B")):

hash of packet C produced by:

(
    C
    +
    (
        double
        +
        C1
    )
    +
    (
        (
            A
            +
            (
                long
                +
                A1
            )
        )
        +
        C2
    )
    +
    (
        (
            Parser::token::MAP
            +
            int
            +
            (
                A
                +
                (
                    long
                    +
                    A1
                )
            )
        )
        +
        C3
    )
    +
    (
        (
            Parser::token::LIST
            +
            (
                B
                +
                (
                    short
                    +
                    B1
                )
            )
        )
        +
        C4
    )
)

NOTE:

dependency to Parser::token::MAP and LIST while hash calculation may unexpectedly change hash result if flex/bison implementations vary.

krystal's People

Contributors

rakjin avatar

Watchers

James Cloos avatar  avatar

krystal's Issues

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.