Coder Social home page Coder Social logo

cx's People

Contributors

mrpeanutbutta avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

rackbone dtscode

cx's Issues

for expression type check

This should be a valid expression, but currently is not.

  18 1:     for(int i = 0; mf[i]; i++){
                                ^
*** error: Incompatible types
Too many syntax errors.  Translation aborted.
*** fatal translator error: Too many syntax errors

design documents

documenting the design of basic functionality.

documents can be found in doc/

Switch statements

I believe the only thing left to complete basic statements is adding a c like switch statement

cxctype

will track the progress of Cx cxctype library here.

multi-dimensional arrays

multi-dimensional arrays should not be very difficult to implement. this will need to be complete for issues #51 and #6 to be resolved.

infinite loop with single main function

with a single main function in the script, if a return statement is executed, the executor will see token tc_dot_dot_dot instead of tc_dummy. this causes the executor to loop.

see Cx/examples/hex.Cx for replicating the issue.

function protoypes

currently functions must appear before main in the script.

need to create a way to declare function prototypes.

file::close / file::reopen

closing a file before file::reopen causes segfault in linux.

#include stdio

int main () {

    file myfile;

    if(!myfile.open(filename, "w"))
        perror("error opening file: " + filename);
    else {

        myfile.puts("test");

        myfile.close; // <-- will crash on file::reopen
    }

    if(!myfile.reopen(filename, "r")) // <-- will crash
        perror("error reopening file: " + filename);
    else {

        while(!myfile.eof){
            puts(myfile.getc.to_str);
        }

        myfile.close;
    }

    return 0;
}

do.cpp - wrong statement

In do.cpp, there's a call to execute_statement_list at line 23, this need to be execute_statement().

commandline arguments

need to implement arguments to script main.

  • argv() - function to tokenize space separated command line arguments.
  • argc() - returns and integer count of the number of arguments.
int main(){

   char *cmdopt;

   do {
     cmdopt = argv();        // gets next string int the command line args
   } while(cmdopt != null);

    return 0;
}

temporary value allocation

Temporary value allocation works for array types. I need to fix it to work with primitive types and arrays of those types.

example:

char c = 'c';
char *cx = "cx";

// cx + c allocates 3 char array and is assigned to cc
char *cc = cx + c;

working example:

// gets() and string allocation example

#include cxstdio

int main () {

    do{
        puts("Please enter your name: ");
        // read string until '\n'
        char *in = gets();
    }while(!in);

    char *t1 = "beep";
    char *t2 = "-boop";
    char *greet = "Hello " + in + ", you a bad " + t1 + t2 + " !";

    puts(greet);

    return 0;
}

issue with float type

using basic float type is causing undefined behavior.

int i = 2;
float f 3.3;

//causing UB
f += i;

malloc - incorrect checksum for freed object

Ran into something interesting while dev'ing radix scanning.
Seems to be triggered by floating point.

Successful completion. 9 statements executed.
cx(24808) malloc: *** error for object 0x100103120: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug

Cx clearly hates floating point Fibonacci.

full dump

Page 1   ./examples/radix.Cx   Tue Aug  6 16:14:21 2013

   1 0:
   2 0:
   3 0: int main(){
   4 1:     // hex test
   5 1:     int x = 0xffff;
   6 1:     int y = 0xabcdef;
   7 1:     int a = x << 3;
   8 1:
   9 1:     // octal test, should == 83 in decimal
  10 1:     int oct = 0123;
  11 1:
  12 1:     // binary test, should == 83 in decimal
  13 1:     int bin = 0b01010011;
  14 1:
  15 1:     // lets make sure octal does not fuck with float values starting in zero
  16 1:     float flo = 0.11235; // i think this may be causing an issue.
  17 1:
  18 1:     __cx_stdout__ = a;
  19 1:
  20 1:     return 0;
  21 1: }
  22 1:

                  22 source lines.
                   0 syntax errors.

>> Entering routine __cx_global__
>>  At 3
>> Entering routine main
>>  At 5
>>   x <== 65535
>>  At 6
>>   y <== 11259375
>>  At 7
>>   x: 65535
>>   a <== 524280
>>  At 10
>>   oct <== 83
>>  At 13
>>   bin <== 83
>>  At 16
>>   flo <== 0.11235
>>  At 18
>>   a: 524280
524280>>   __cx_stdout__ <== >>  At 20
>>   main <== 0
>> Exiting routine main
>> Exiting routine __cx_global__

Successful completion.  9 statements executed.
cx(24936) malloc: *** error for object 0x1011031e0: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

return - causing recurssion issues

fixed an issue with return statements causing a recursive issue in icode.

when 'return' is executed, goto would attempt to go to the end of the function. this was causing recursive function calls with a larger size script.

return now simply sets the current token to tc_dummy after assignment.

input/output

requires issue #6 to be completed.

should be part of stdlib.

runtime stack redesign

redesigning runtime stack with std::vector. this will allow for dynamic stack allocations and provide the needed control via iterators that std::stack is missing.

temp rvalue incorrect

The following code produces incorrect results.

Please enter your name: 
aaron
FUCKA !aron, you a bad MUTHA
/* gets() and string allocation example
 */
#include cxstdio
#include cxctype

int main () {

    do{
        puts("Please enter your name: ");

        // read string until '\n'
        char *in = gets();
    }while(!in);

    char *mf = "mutha" + "-fucka";

    int i = 0;
    char *s;
    while(mf[i] != '\0'){
        s += toupper(mf[i]);
        i++;
    }

    char *greet = "Hello " + in + ", you a bad " + s + " !";

    puts(greet);

    return 0;
}

wchar literals denoted with L

need to add the ability to allocate wide character literals.
wide char (wchar) literals are denoted with L.

example:

wchar  c = L"this is allocated as a wide char array.";

Code cleanup

Code cleanup and organization is needed.

Also, the repo readme needs to have a better explanation of what the project is about.

function overloading

need to implement function overloading.

funciton names should be appended with parameter type names.

char::is_xdigit - logic error

((this >= 'A') || (this == 'F')) shoud be ((this >= 'A') && (this <= 'F'))

    bool is_xdigit(){
        return  (((this >= 'a') && (this <= 'f')) ||
                ((this >= 'A') || (this == 'F')) ||
                (this.is_digit));
    }

each iterator

tracking progress on each iterator.
.each() will be treated as a function block with compound execution optional.
example:

char *c = "each";
// execute single statement
c.each(char a) puts(a.to_str);

or

char *c = "each";
// execute compounded statements
c.each(char a) {
    puts(a.to_str);
    puts(a.to_str);
    puts(a.to_str);
}

by reference

char *c = "each";
// execute single statement
c.each(char &a) puts(a.to_str);

Scoped code blocks

A new symtab scope should be entered when compounded statements are grouped by { and }.

New symtab but same icode? Idk will have to check.

namespaced types has issue declaring instance

declaring an instance of a type from within a namespace doesn't work.

#include io

int main(){
    io::file in; // << while throw an error

    return 0;
}
   8 1:         io::file in;
                           ^
*** error: Undefined identifier

Legacy NULL changes

NULL should be changed to nullptr throughout CX.

Will be making changes on methods and types that are considered dated.

arrays need standard members

currently this code is I broken. arrays need basic standard members.

#include stdio

int main () {
    int a = 101010101;
    puts(a.to_str.length.to_str);
    return 0;
}

Escape sequences needed

NL(LF) \n HT \t VT \v
BS \b CR \r FF \f BEL \a
\ \\
? \?
’ \’
" \" ooo \ooo hhh \xhhh


Type casting

Type casting should be among factors followed by parse/execute expression.

Int I = (int) 1.2;

Init list

Added initialization list for array types

namespace

Global scope will be allowed only in named spaces. Any types needing global scope will have to be within a namespace. This does not apply to functions and class body's.

exec.cpp - runtime stack makeover

The runtime stack is statically allocated. I would like to change this by using the stdlib stack container.

Pop should return an iterator to the top-of-stack StackItem, but leave the item in place.
An iterator would be incremented/decremented to perform push/pop, but pushes can allocate new space if the stack is on the verge of being over run.

Of course push allocation should be limited, but what would be a good size limit?
Should the std::stack handle out-of-memory exceptions?

class/namespace allocation of variables

See #84

need allocation of locals in namespace or class.

need to insert node pointers into icode and allocate variables as they appear.

this may be done in
prs_stmt.cpp - insert into icode
stmt.cpp - allocate as they show up (in seq) in icode

parse_directive.cpp - #include - needs fixing

include should avoid inserting 'main' while processing headers by setting

pProgram_ptr->pProgram_ptr->foundGlobalEnd = true;

then after processing

pProgram_ptr->foundGlobalEnd = false;

cx-doc - project

once the interpreter is complete a language documentation project will be sarted

complete basic types

types completed this far:

const - qualifier,
int, bool, float, char, wchar, byte and single index arrays of these types.

needed:
multidimension arrays

io/libio

will track the progress of Cx cxstdio library here.

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.