Skip to content

Commit

Permalink
Command line fixes and more (read CHANGELOG)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Mar 16, 2010
1 parent 3f5961c commit 1002702
Show file tree
Hide file tree
Showing 45 changed files with 24 additions and 68 deletions.
Empty file modified LICENSE 100755 → 100644
Empty file.
1 change: 0 additions & 1 deletion Makefile 100755 → 100644
Expand Up @@ -16,7 +16,6 @@ hybris: builtins
g++ -c src/lexer.cpp $(CFLAGS)
g++ -c src/builtin.cpp $(CFLAGS)
g++ -c src/vmem.cpp $(CFLAGS)
g++ -c src/cmdline.cpp $(CFLAGS)
g++ -c src/node.cpp $(CFLAGS)
g++ -c src/object.cpp $(CFLAGS)
g++ -c src/tree.cpp $(CFLAGS)
Expand Down
Empty file modified README 100755 → 100644
Empty file.
Empty file modified examples/Makefile 100755 → 100644
Empty file.
Empty file modified examples/libtest.cc 100755 → 100644
Empty file.
Empty file modified examples/passed.zip 100755 → 100644
Empty file.
Empty file modified examples/test.dat 100755 → 100644
Empty file.
Empty file modified examples/test.xml 100755 → 100644
Empty file.
Empty file modified hybris.cbp 100755 → 100644
Empty file.
Empty file modified include/builtin.h 100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion include/common.h 100755 → 100644
Expand Up @@ -38,7 +38,7 @@ typedef struct {
function_decl_t;

typedef enum {
H_NONE,
H_NONE = 0,
H_EXECUTE,
H_COMPILE,
H_RUN
Expand Down
2 changes: 1 addition & 1 deletion include/config.h 100755 → 100644
Expand Up @@ -20,7 +20,7 @@
# define _HCONFIG_H_

#define AUTHOR "The Hybris Dev Team [http://www.hybris-lang.org/]"
#define VERSION "0.7b"
#define VERSION "0.7.1b"

// system path for libraries (.so dynamic libs)
#define LIBS_PATH "/usr/lib/hybris/libs/"
Expand Down
Empty file modified include/hybris.h 100755 → 100644
Empty file.
Empty file modified include/map.h 100755 → 100644
Empty file.
Empty file modified include/node.h 100755 → 100644
Empty file.
Empty file modified include/object.h 100755 → 100644
Empty file.
Empty file modified include/tree.h 100755 → 100644
Empty file.
Empty file modified include/vmem.h 100755 → 100644
Empty file.
Empty file modified src/builtin.cpp 100755 → 100644
Empty file.
Empty file modified src/builtins/array.cc 100755 → 100644
Empty file.
Empty file modified src/builtins/conio.cc 100755 → 100644
Empty file.
Empty file modified src/builtins/dll.cc 100755 → 100644
Empty file.
Empty file modified src/builtins/encoding.cc 100755 → 100644
Empty file.
Empty file modified src/builtins/fileio.cc 100755 → 100644
Empty file.
Empty file modified src/builtins/http.cc 100755 → 100644
Empty file.
Empty file modified src/builtins/map.cc 100755 → 100644
Empty file.
Empty file modified src/builtins/math.cc 100755 → 100644
Empty file.
Empty file modified src/builtins/matrix.cc 100755 → 100644
Empty file.
Empty file modified src/builtins/netio.cc 100755 → 100644
Empty file.
Empty file modified src/builtins/pcre.cc 100755 → 100644
Empty file.
Empty file modified src/builtins/process.cc 100755 → 100644
Empty file.
Empty file modified src/builtins/pthreads.cc 100755 → 100644
Empty file.
Empty file modified src/builtins/reflection.cc 100755 → 100644
Empty file.
Empty file modified src/builtins/string.cc 100755 → 100644
Empty file.
Empty file modified src/builtins/time.cc 100755 → 100644
Empty file.
Empty file modified src/builtins/type.cc 100755 → 100644
Empty file.
Empty file modified src/builtins/xml.cc 100755 → 100644
Empty file.
Empty file modified src/common.cpp 100755 → 100644
Empty file.
Empty file modified src/hybris.cpp 100755 → 100644
Empty file.
Empty file modified src/lexer.l.cpp 100755 → 100644
Empty file.
Empty file modified src/node.cpp 100755 → 100644
Empty file.
Empty file modified src/object.cpp 100755 → 100644
Empty file.
87 changes: 22 additions & 65 deletions src/parser.y.cpp 100755 → 100644
Expand Up @@ -19,7 +19,6 @@
*/

#include "hybris.h"
#include "cmdline.h"

#define YY_(s) (char *)s

Expand Down Expand Up @@ -198,92 +197,50 @@ int h_banner(){

int h_usage( char *argvz ){
h_banner();
printf( /*"\nUsage: %s (action) (-o output) file (--trace)\n"*/
"\nUsage: %s (action) file (--trace)\n"
"Where action could be :\n"
"\t-e : Execute the script as an interpreter .\n\n"
/*"\t-c : Compile the script in x-byte-code and save it to 'output' .\n"
"\t-r : Load the x-byte-code from 'file' and run it .\n\n"*/
"\t--trace : Will enable stack trace report on errors .\n\n"
"Notes :\n"
"If no action is specified, it's assumed as '-e file' .\n\n"
/* "If -c is set and no output is specified, the file will be compiled into 'output.ch' .\n\n" */ , argvz );
printf( "\nUsage: %s file (--trace)\n"
"\t--trace : Will enable stack trace report on errors .\n\n", argvz );
return 0;
}

int main( int argc, char *argv[] ){
if( argc < 2 ){
return h_banner();
return h_usage( argv[0] );
}
else{
CmdLine cmdline( argc, argv );

if( cmdline.isset("-h") || cmdline.isset("--help") ){
return h_usage( argv[0] );
}

memset( &HCTX.HARGS, 0x00, sizeof(h_args_t) );
if( cmdline.isset( "-e" ) ){
cmdline.get( "-e", HCTX.HARGS.source );
HCTX.HARGS.action = H_EXECUTE;
}
else if( cmdline.isset( "-c" ) ){
cmdline.get( "-c", HCTX.HARGS.source );
HCTX.HARGS.action = H_COMPILE;
if( cmdline.isset( "-o" ) ){
cmdline.get( "-o", HCTX.HARGS.destination );
int i, f_offset = 0;
for( i = 0; i < argc; i++ ){
if( strcmp( argv[i], "--trace" ) == 0 ){
HCTX.HARGS.stacktrace = 1;
}
else{
strcpy( HCTX.HARGS.destination, "output.ch" );
f_offset = i;
}
}
else if( cmdline.isset( "-r" ) ){
cmdline.get( "-r", HCTX.HARGS.source );
HCTX.HARGS.action = H_RUN;
}
else{
cmdline.nonFlaggedArg( HCTX.HARGS.source );
HCTX.HARGS.action = H_EXECUTE;
}

HCTX.HARGS.stacktrace = cmdline.isset("--trace");
HCTX.HARGS.action = H_EXECUTE;
strncpy( HCTX.HARGS.source, argv[f_offset], sizeof(HCTX.HARGS.source) );

if( h_file_exists(HCTX.HARGS.source) == 0 ){
printf( "Error :'%s' no such file or directory .\n\n", HCTX.HARGS.source );
return h_usage( argv[0] );
if( f_offset > 0 ){
if( h_file_exists(HCTX.HARGS.source) == 0 ){
printf( "Error :'%s' no such file or directory .\n\n", HCTX.HARGS.source );
return h_usage( argv[0] );
}
}

h_env_init( &HCTX, argc, argv );

/* compile or execute */
if( HCTX.HARGS.action != H_RUN ){
extern FILE *yyin;
yyin = fopen( HCTX.HARGS.source, "r");
extern FILE *yyin;
yyin = f_offset > 0 ? fopen( HCTX.HARGS.source, "r") : stdin;

h_changepath( &HCTX );
while( !feof(yyin) ){
yyparse();
}
h_changepath( &HCTX );
while( !feof(yyin) ){
yyparse();
}
if( f_offset > 0 ){
fclose(yyin);
}
/* run pseudo-compiled byte code
else{
FILE *input = fopen( HARGS.source, "rb" );
h_changepath();
if( h_check_header(input) == 0 ){
fclose(input);
hybris_generic_error( "'%s' damaged or invalid file", HARGS.source );
}

while( !feof(input) ){
Node *tree = htree_load(input);
htree_execute(&HVM,tree);
Tree::release(tree);
}
fclose(input);
}
*/
h_env_release(&HCTX);
}

Expand Down
Empty file modified src/tree.cpp 100755 → 100644
Empty file.
Empty file modified src/vmem.cpp 100755 → 100644
Empty file.

0 comments on commit 1002702

Please sign in to comment.