Coder Social home page Coder Social logo

csharp.interpreter's Introduction

csharp.interpreter's People

Contributors

botnaughts avatar gateauxd avatar mutilar avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

csharp.interpreter's Issues

Feature: Arrays

Add support for the "[]" string, creating array data objects. There are a few cases to consider for how one might declare an array in C#. In the variable handler, array[0] could be saved as "array0", array[1] as "array1", etc.

int[] values = new int[10];
float[] other_values = new float[] { 10.2, 3.4 };

Feature: Switch casing

Add support for the "switch" keyword and, implicitly, the "case" and "default" keywords. This will require attention in adjusting how the interpreter handles "break" statements and custom pointer manipulation for the conditional cases.

switch (value) {
   case "yes":
   break;
   case "no":
   break;
   default:
   break;
}

Feature: Substring Handler

A Substring handler to deal with the many times a Substring function is called would significantly improve readability of code.

e.g. "SubstringHandler.TrimTo(FIRST_INSTANCE_OF, "(", LAST_INSTANCE OF, ")");"

Rework: Part by Part Parsing/Visualizing

Instead of stepping and switching by line, the interpreter would be more accurate and visually educational if it stepped per part of each line.

e.g.

if (x + 5 == 7) {

would first fetch any variable values from memory (an EEPROM):

if (2 + 5 == 7) {

then step through PEMDAS if need-be:

if (7 == 7) {

and lastly the evaluation (which is still in PEMDAS technically...):

if (true) {

This simplified "if true" would then be passed into the original interpreter to control scope and flow control (see ScopeHandler).

It gets more complicated with function calls mid-line, but this is where the current interpreter fails. Thus, this is an imperative to-do to allow for as versatile code inputs as possible.

Feature: If/Else/Else If logic

Add support for the "else" keyword and, implicitly, the "else if" combination. This will require attention in managing the pointer on closing bracket of an if statement to ensure that it jumps past ignored unsatisfied conditionals.

if (i == 0) {
}
else if (i & 2 == 0) {
}
else { 
}

Code Visualization

Code, algorithm, data interpreted via plots, graphs, and other visual elements

Feature: Misc. Generic Objects

Add support for various objects that will be of use to a player. Each object will have its own rules and conditions to follow. For example, a Vector2 has two float members, "x" and "y". Other data types will have their own hard-coded list of variable object members.

Vector2 point = new Vector2(10.2, 3.4);

Reworking Interpreter Stepping to Reflect Underlying Assembly Logic

Controlling speed of code interpreting (which, from a game-play aspect, is highly relevant) needs to consider underlying clock cycles from an assembly perspective to better estimate and step through the script.

To facilitate this, it will require a new object-oriented reworking of the interpreter to clearly define an Action, which ScopeAction, AssignmentAction, ArithmeticAction, etc. would inherit. Actions would have the current scope they were executed on, which would hold scope-visible variables.

The Interpreter would work on each Step() to determine what the next Action it needs to take is, then take that Action. It would never execute more than one action in a clock cycle. Actions could also be set to take a certain number of clock cycles to complete, meaning subsequent calls to Step() would be working to decrement a clock_cycles_left sort of counter before finding the next Action to execute.

This would result in a highly flexible, tune-able interpreter with improved readability from a coding perspective, where logic for isolating and executing Actions would be distinct and independent functionalities.

It also works to incentivize players to write code that works efficiently and logically, as inefficiency in their code execute would be very obviously hampering ship performance. To help players analyze their script execution, all Actions can be logged and viewed as an execution tree, built from the scope queue.

Feature: Foreach loops

Add support for the "foreach" keyword. This is a rather difficult prospect in controlling the flow behind the scenes and iterating across a given array (note, arrays are not implemented at this time).

foreach (int value in array_of_values) {
}

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.