Zomis / Brainduck

Brainfuck Interpreter in Java/Groovy, with a Groovy DSL
40 stars 1 forks source link

IDE Match code to memory #17

Closed Zomis closed 8 years ago

Zomis commented 9 years ago

Use highlighting in the IDE, related to #14, so that code is matched to which memory cells it is doing work on, so that you when coding can move around in your code, at "compile time", and see where the memory marker is when that piece of code is running.

Zomis commented 9 years ago

This could be called Code - Cell Relationship. It is essentially a many-to-many relationship between code and cells.

Possible implementation:

class CodeCellRelationship {
    Map<Integer, Set<Integer>> codeToCells
    Map<Integer, Set<Integer>> cellsToCode
}

The Set<Integer> could perhaps be a Range or a YKXMRange (y = kx + m formula within a range) or similar.

cellsToCode will likely have a range of values in it, such as all indexes from 25 to 42.

Code should match up to the cells by checking the cell it is being performed at, > will point to the cell it is going from, which is the cell it was at when it performed the command, Just like with + - [ ] . ,

Zomis commented 9 years ago

Just a thought, this could possibly allow detection of 'variable scope'. It might be that some values are only accessed within a limited scope.

Examples:

FizzBuzz indicator:

>+++++ +++++ [-
$ loop 'setupFizz'
>+++++ ++
>+++++ +++++
>+++++ +++++ ++
>+++++ +++++ ++
<<<<]
+++                                Set modulo value to 3
(...) read and decreased much later.

Asciitable original:

        Comparer: num1 num2 out 0 0
        [
            -
            >-
            >>>+
            <<<<
        ]