From ed4822ee29f2272d4d82677529bfe6483d1973b7 Mon Sep 17 00:00:00 2001 From: arookas Date: Mon, 28 Dec 2015 23:24:08 -0500 Subject: [PATCH] Moved dump and print to common.sun. --- ssc/ast/nodes.system.cs | 24 ------------------------ ssc/context.cs | 2 -- ssc/parser.cs | 6 +----- ssc/sunscript.grammar | 6 ------ stdlib/common.sun | 4 ++++ 5 files changed, 5 insertions(+), 37 deletions(-) diff --git a/ssc/ast/nodes.system.cs b/ssc/ast/nodes.system.cs index ecae703..39dca48 100644 --- a/ssc/ast/nodes.system.cs +++ b/ssc/ast/nodes.system.cs @@ -18,16 +18,6 @@ var builtinInfo = context.ResolveSystemBuiltin("exit"); context.Text.WriteFUNC(builtinInfo.Index, 0); context.Text.WritePOP(); - } - } - - class sunDump : sunNode { - public sunDump(sunSourceLocation location) - : base(location) { } - - public override void Compile(sunContext context) { - var builtinInfo = context.ResolveSystemBuiltin("dump"); - context.Text.WriteFUNC(builtinInfo.Index, 0); context.Text.WritePOP(); } } @@ -96,18 +86,4 @@ Compile(context, context.ResolveSystemBuiltin("typeof")); } } - - class sunPrint : sunNode { - public sunNode ArgumentList { get { return this[0]; } } - - public sunPrint(sunSourceLocation location) - : base(location) { } - - public override void Compile(sunContext context) { - var builtinInfo = context.ResolveSystemBuiltin("print"); - ArgumentList.Compile(context); - context.Text.WriteFUNC(builtinInfo.Index, ArgumentList.Count); - context.Text.WritePOP(); - } - } } diff --git a/ssc/context.cs b/ssc/context.cs index 5f5a288..58deb30 100644 --- a/ssc/context.cs +++ b/ssc/context.cs @@ -59,13 +59,11 @@ namespace arookas { // add system builtins DeclareSystemBuiltin("yield", false); DeclareSystemBuiltin("exit", false); - DeclareSystemBuiltin("dump", false); DeclareSystemBuiltin("lock", false); DeclareSystemBuiltin("unlock", false); DeclareSystemBuiltin("int", false, "x"); DeclareSystemBuiltin("float", false, "x"); DeclareSystemBuiltin("typeof", false, "x"); - DeclareSystemBuiltin("print", true); } public void Close() { if (!mOpen) { diff --git a/ssc/parser.cs b/ssc/parser.cs index 962f039..dc8c6b7 100644 --- a/ssc/parser.cs +++ b/ssc/parser.cs @@ -8,7 +8,7 @@ namespace arookas { "builtin", "function", "var", "const", "if", "while", "do", "for", "return", "break", "continue", - "yield", "exit", "dump", "lock", "unlock", "int", "float", "typeof", "print", + "yield", "exit", "lock", "unlock", "int", "float", "typeof", "true", "false", }; @@ -83,10 +83,8 @@ namespace arookas { case __sunConstants.YIELD_STATEMENT: return new sunYield(location); case __sunConstants.EXIT_STATEMENT: return new sunExit(location); - case __sunConstants.DUMP_STATEMENT: return new sunDump(location); case __sunConstants.LOCK_STATEMENT: return new sunLock(location); case __sunConstants.UNLOCK_STATEMENT: return new sunUnlock(location); - case __sunConstants.PRINT_STATEMENT: return new sunPrint(location); } // literals @@ -234,13 +232,11 @@ namespace arookas { case __sunConstants.YIELD: case __sunConstants.EXIT: - case __sunConstants.DUMP: case __sunConstants.LOCK: case __sunConstants.UNLOCK: case __sunConstants.INT: case __sunConstants.FLOAT: case __sunConstants.TYPEOF: - case __sunConstants.PRINT: case __sunConstants.TRUE: case __sunConstants.FALSE: diff --git a/ssc/sunscript.grammar b/ssc/sunscript.grammar index 896d8de..45d965a 100644 --- a/ssc/sunscript.grammar +++ b/ssc/sunscript.grammar @@ -41,13 +41,11 @@ CONTINUE = "continue" YIELD = "yield" EXIT = "exit" -DUMP = "dump" LOCK = "lock" UNLOCK = "unlock" INT = "int" FLOAT = "float" TYPEOF = "typeof" -PRINT = "print" TRUE = "true" FALSE = "false" @@ -131,7 +129,6 @@ statement = continue_statement SEMICOLON | yield_statement SEMICOLON | exit_statement SEMICOLON | - dump_statement SEMICOLON | lock_statement SEMICOLON | unlock_statement SEMICOLON | statement_block; @@ -142,17 +139,14 @@ compound_statement_item = variable_declaration | variable_assignment | variable_augment | - print_statement | function_call; statement_block = L_BRACE {statement} R_BRACE; import_statement = IMPORT STRING; yield_statement = YIELD; exit_statement = EXIT; -dump_statement = DUMP; lock_statement = LOCK; unlock_statement = UNLOCK; -print_statement = PRINT argument_list; name_label = IDENTIFIER COLON; diff --git a/stdlib/common.sun b/stdlib/common.sun index 4f0bc09..31f70dc 100644 --- a/stdlib/common.sun +++ b/stdlib/common.sun @@ -10,6 +10,10 @@ const TYPE_INT = 0; const TYPE_FLOAT = 1; const TYPE_STRING = 2; +// debug +builtin dump(); +builtin print(...); + import "system.sun"; import "talk.sun"; import "sound.sun";