mrpeanutbutta / cx Goto Github PK
View Code? Open in Web Editor NEWA scripting language for fun and profit.
License: MIT License
A scripting language for fun and profit.
License: MIT License
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
new allocation should invoke a constructor call.
documenting the design of basic functionality.
documents can be found in doc/
I believe the only thing left to complete basic statements is adding a c like switch statement
will track the progress of Cx cxctype library here.
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.
need to finish classes and members.
currently functions must appear before main in the script.
need to create a way to declare function prototypes.
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;
}
int pow2(int b){
return b <<= 1; // Value of b gets popped off thus pow2 gets wrong value.
}
int b = 5;
return pow2(b);
In do.cpp, there's a call to execute_statement_list at line 23, this need to be execute_statement().
need to implement arguments to script main.
int main(){
char *cmdopt;
do {
cmdopt = argv(); // gets next string int the command line args
} while(cmdopt != null);
return 0;
}
In the process of converting names to lower case. this will be across the entire project.
need to tidy up pretty print and tracing.
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;
}
using basic float type is causing undefined behavior.
int i = 2;
float f 3.3;
//causing UB
f += i;
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
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.
requires issue #6 to be completed.
should be part of stdlib.
needs to scan and tokenize other number bases.
current: real, integer
needed: binary, hex, and octal
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.
needs implementation
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;
}
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 and organization is needed.
Also, the repo readme needs to have a better explanation of what the project is about.
need to implement function overloading.
funciton names should be appended with parameter type names.
expressions type casts should be valid. currently is not acceptable.
io::puts((result.to_int * 2).to_str);
19 1: io::puts((result.to_int * 2).to_str);
^
*** error: Missing )
need to add wget for unicode chars.
current integer scanning does not represent the true numerical size of int type.
((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));
}
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);
A new symtab scope should be entered when compounded statements are grouped by { and }.
New symtab but same icode? Idk will have to check.
leading a string cat expression with a char causes segfault
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
NULL should be changed to nullptr throughout CX.
Will be making changes on methods and types that are considered dated.
Need new char operations. C2I, CLOAD, CSTORE...etc...
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;
}
NL(LF) \n HT \t VT \v
BS \b CR \r FF \f BEL \a
\ \\
? \?
’ \’
" \" ooo \ooo hhh \xhhh

Need to define new operation and heap allocation for objects.
need to complete character type.
basic, literal and array form
Type casting should be among factors followed by parse/execute expression.
Int I = (int) 1.2;
Added initialization list for array types
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.
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?
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
pProgram_ptr->pProgram_ptr->foundGlobalEnd = true;
then after processing
pProgram_ptr->foundGlobalEnd = false;
once the interpreter is complete a language documentation project will be sarted
types completed this far:
const - qualifier,
int, bool, float, char, wchar, byte and single index arrays of these types.
needed:
multidimension arrays
will track the progress of Cx cxstdio library here.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.