Code Monkey home page Code Monkey logo

hackedinterpreter's Introduction

HackedInterpreter

HackedInterpreter is a featurecomplete interpreter for the H language which is used in http://hackedapp.com. This interpreter has supports C-style comments in code files, which the original language doesn't at the moment.

Compiling

  1. install golang
  2. get the sources
  3. run go get code.google.com/p/gocc to get the parser engine
  4. run go get github.com/nsf/termbox-go to get the termbox package
  5. run go build

Modifying the Syntax

The syntax is declared in the hacked.bnf file and will be compiled by gocc. To update the sourcecode run gocc -p="github.com/boombuler/hackedinterpreter" hacked.bnf and rebuild with go build

Executing Code

Simply call the compiled binary with the code you want to execute. By default all code execution will be terminated, if the program runs more than 5 seconds.

Examples

  • Simple execution. hackedinterpreter example.h
  • With timeout set. hackedinterpreter -timeout=10s example.h
  • With given input. the input is parsed as H-Syntax too. But the parsing will be canceled if it doesn't parse in 100 milliseconds. hackedinterpreter -input="[1, 2, 3]" example.h
  • Start a game. Controls: Keyboard Up / Down / Left / Right / A / B hackedinterpreter -game game.h

Debugging

To start debugging start the program with -debug parameter. Once the debugger is attached it will wait before executing any code. On the right side you see the current state of each variable.

Controls

You can move the code around with the arrow keys. Once the debugger stopped code execution you can step over each single command by pressing s. If you want to continue the code execution till the next breakpoint press c to continue execution. You can enter debugger commands by pressing Enter and enter one of the following commands:

  • bpx [Line] will toggle a code breakpoint on the given line.
  • bpr [var name] will toggle a memory breakpoint. Which will break as soon as any code has read the content of the given variable. Example: bpr var_a will break on code like var_c = var_a * 3
  • bpw [var name] will toggle a memory breakpoint. Which will break as soon as any code has set the value of the given variable. Example: bpw var_a will break on code like var_a = abs(var_b)
  • eval [code] will execute the given code. For example you can call eval var_a = abs(var_b) to set the current value of var_a. If the given code will is faulty nothing will happen, and you will not get any result of the given code.

The Esc key stops execution will exit the debugger

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.