From 5bba655088b0729dbd37c2ca8d8b5be98bb2f19e Mon Sep 17 00:00:00 2001 From: Valk Richard Li <48872266+ValKmjolnir@users.noreply.github.com> Date: Sun, 31 May 2020 10:19:26 -0700 Subject: [PATCH] the beginning of a new interpreter --- version3.0/lib/base.nas | 172 ++++++++++++++++++++++++++++++++++++ version3.0/lib/bits.nas | 36 ++++++++ version3.0/lib/io.nas | 74 ++++++++++++++++ version3.0/lib/math.nas | 49 ++++++++++ version3.0/lib/readline.nas | 12 +++ version3.0/lib/regex.nas | 12 +++ version3.0/lib/sqlite.nas | 15 ++++ version3.0/lib/system.nas | 9 ++ version3.0/lib/thread.nas | 17 ++++ version3.0/lib/unix.nas | 22 +++++ version3.0/lib/utf8.nas | 15 ++++ version3.0/main.cpp | 99 +++++++++++++++++++++ version3.0/nasal.h | 22 +++++ version3.0/nasal_enum.h | 21 +++++ version3.0/nasal_lexer.h | 99 +++++++++++++++++++++ version3.0/nasal_resource.h | 97 ++++++++++++++++++++ 16 files changed, 771 insertions(+) create mode 100644 version3.0/lib/base.nas create mode 100644 version3.0/lib/bits.nas create mode 100644 version3.0/lib/io.nas create mode 100644 version3.0/lib/math.nas create mode 100644 version3.0/lib/readline.nas create mode 100644 version3.0/lib/regex.nas create mode 100644 version3.0/lib/sqlite.nas create mode 100644 version3.0/lib/system.nas create mode 100644 version3.0/lib/thread.nas create mode 100644 version3.0/lib/unix.nas create mode 100644 version3.0/lib/utf8.nas create mode 100644 version3.0/main.cpp create mode 100644 version3.0/nasal.h create mode 100644 version3.0/nasal_enum.h create mode 100644 version3.0/nasal_lexer.h create mode 100644 version3.0/nasal_resource.h diff --git a/version3.0/lib/base.nas b/version3.0/lib/base.nas new file mode 100644 index 0000000..f99e814 --- /dev/null +++ b/version3.0/lib/base.nas @@ -0,0 +1,172 @@ +# nasal lib base.nas +# 2020/2/4 +# this file is used to avoid name confliction +# and is used to avoid name undefined +# before running this file will be translated to abstract syntax tree +# and this ast will be linked before main ast as main-ast's beginning + +# append +# The first argument specifies a vector. +# Appends the remaining arguments to the end of the vector. +var append=func(vector,elements...) +{ + nasal_call_builtin_push_back(vector,elements); + return nil; +} + +# setsize +# Sets the size of a vector. +# The first argument specifies a vector, the second a number representing the desired size of that vector. +# If the vector is currently larger than the specified size,it is truncated. +# If it is smaller, it is padded with nil entries.Returns the vector operated upon. +var setsize=func(vector,__size) +{ + nasal_call_builtin_set_size(vector,__size); + return nil; +} + +# subvec +# Returns a sub-range of a vector. +# The first argument specifies a vector, the second a starting index, +# and the optional third argument indicates a length (the default is to the end of the vector). +var subvec=func(vector,start,length=nil) +{ + return nasal_call_builtin_subvec(vector,start,length); +} + +# contains +# The first argument specifies a hash, the second must be a scalar. +# Returns 1 if the hash contains the scalar as a key, 0 if not. +var contains=func(hash,key) +{ + return nasal_call_builtin_contains(hash,key); +} + +# delete +# The first argument specifies a hash, the second must be a scalar key. +# Deletes the key from the hash if it exists. +# Operationally, this is identical to setting the hash value specified by the key to nil, +# but this variant potentially frees storage by deleting the reference to the key and by shrinking the hash. +var delete=func(hash,key) +{ + nasal_call_builtin_delete(hash,key); + return; +} + +# int +# Returns the integer part of the numeric value of the single argument, or nil if none exists. +# Truncates towards zero, not negative infinity (i.e. it's implemented in C as a double tointeger typecast). +var int=func(value) +{ + return nasal_call_builtin_trans_int(value); +} + +# num +# Returns the numeric value of the single argument, or nil if none exists. +var num=func(value) +{ + return nasal_call_builtin_trans_num(value); +} + +# keys +# Returns a vector containing the list of keys found in the single hash argument. +var keys=func(hash) +{ + return nasal_call_builtin_get_keys(hash); +} + +# pop +# Removes and returns the last element of the single vector argument. +var pop=func(vector) +{ + return nasal_call_builtin_pop_back(vector); +} + +# size +# Returns the size of the single argument. +# For strings, this is the length in bytes. +# For vectors, this is the number of elements. +# For hashes, it is the number of key/value pairs. +# Returns nil for number and nil arguments. +var size=func(object) +{ + return nasal_call_builtin_sizeof(object); +} + +# streq +# Tests the string values of the two arguments for equality. +# Needed because the == operator in Nasal tests for numeric equality, as in perl. +# So "0" == "0.0" is true,but streq("0", "0.0") is false. +# This is rarely required in typical code. +var streq=func(__a,__b) +{ + return nasal_call_builtin_str_cmp_equal(__a,__b); +} + +# cmp +# Compares two strings, returning -1 if a is less than b, 0 if theyare identical, and 1 if a is greater than b. +var cmp=func(__a,__b) +{ + return nasal_call_builtin_cmp(__a,__b); +} + +# sort +# Creates a new vector containing the elements in the input vector sorted in ascending order according to the rule givenby function, +# which takes two arguments (elements of the input vector) and should return less than zero, zero, or greater than zero if the first argument is, +# respectively, less than, equal to, or greater than the second argument. Despite being implemented with ANSI C qsort(), +# the sort is stable; "equal" elements in the output vector will appear in the same relative order as they do in the input. +var sort=func(vector,function) +{ + nasal_call_builtin_cpp_sort(vector,function); + return; +} + +# substr +# Computes a substring. +# The first argument specifes a string, the second is an integer index of the start of a substring, +# the optional third argument specifies a length (the default is to return the remaining string). +# Example: substr("abcde", 1, 3) returns "bcd". +var substr=func(__string,start,length=nil) +{ + return nasal_call_builtin_substr(__string,start,length); +} + +# sprintf +# Creates and returns a string formatted as per ANSI C sprintf(). +var sprintf=func(__format,var_args...) +{ + return nasal_call_builtin_sprintf(__format,var_args); +} + +# find +# Finds and returns the index of the first occurence of the string needle in the string haystack, or -1 if no such occurence was found. +var find=func(needle,haystack) +{ + return nasal_call_builtin_find_first_occur(needle,haystack); +} + +# split +# Splits the input string into a vector of substrings bounded by occurences of the delimeter substring. +var split=func(delimeter,__string) +{ + return nasal_call_builtin_split(delimeter,__string); +} + +# rand +# Returns a random number in the range [0:1) (that is, 0.0 is a possible return value. 1.0 is not). +# If a numeric argument is specified, it is used as a seed instead and the function returns nil. +# Implemented in terms of the C library's rand/srand functions; +# the result should have a full double-precision number's worth of randomness even on systems with a 15 bit rand(). +var rand=func(seed=nil) +{ + return nasal_call_builtin_rand(seed); +} + +# id +# Returns a unique string identifying the object. +# Two id strings are equal if and only if the two references point to the same object in memory. +# Numbers don't have id's and will cause a runtime error if passed to id(). +var id=func(thing) +{ + return nasal_call_builtin_get_id(thing); +} \ No newline at end of file diff --git a/version3.0/lib/bits.nas b/version3.0/lib/bits.nas new file mode 100644 index 0000000..d5b769f --- /dev/null +++ b/version3.0/lib/bits.nas @@ -0,0 +1,36 @@ +# nasal lib bits.nas +# 2020/2/8 +# this file is used to avoid name confliction +# and is used to avoid name undefined +# before running this file will be translated to abstract syntax tree +# and this ast will be linked before main ast as main-ast's beginning + +var bits= +{ + # Interpreting the string str as bits, + # returns the bitfield of the specified length starting at startbit. + # Interprets the result as an unsigned integer. + # The bit order is bytewise big endian: The 0th bit is the high bit of the first byte. + # The last bit is the low bit of the last byte in the string. + fld:func(__string,startbit,length) + { + return nasal_call_builtin_bitcalc(__string,startbit,length); + }, + # As bits.fld(), but interprets the result as a 2's complement signed value. + sfld:func(__string,startbit,length) + { + return nasal_call_builtin_sbitcalc(__string,startbit,length); + }, + # Sets the specified value into the bit string at the specified position. + # The string must be mutable: either the result of a runtime concatenation (the ~ operator) or a call to bits.buf()(see below). + # Attempts to modify immutable strings (e.g. compile time constants) will produce a runtime error. + setfld:func(__string,startbit,length,value) + { + return nasal_call_builtin_setbit(__string,startbit,length,value); + }, + # Returns a zero-filled mutable string of the specified length. + buf:func(length) + { + return nasal_call_builtin_null_string_gen(length); + }, +}; \ No newline at end of file diff --git a/version3.0/lib/io.nas b/version3.0/lib/io.nas new file mode 100644 index 0000000..29c6093 --- /dev/null +++ b/version3.0/lib/io.nas @@ -0,0 +1,74 @@ +# nasal lib io.nas +# 2020/2/8 +# this file is used to avoid name confliction +# and is used to avoid name undefined +# before running this file will be translated to abstract syntax tree +# and this ast will be linked before main ast as main-ast's beginning + +var io= +{ + # Opens the file with the specified mode (as per ANSI fopen()) and returns a ghost object representing the filehandle. + # Failures are thrown as runtime errors as per die(). + open:func(filename,mode="r") + { + return nasal_call_builtin_c_fopen(filename,mode); + }, + # Closes the specified file as per ANSI fclose(). + close:func(filehandle) + { + nasal_call_builtin_c_fclose(filehandle); + return; + }, + # Attempts to read length bytes from the filehandle into the beginning of the mutable string buf. + # Failures (including overruns when length > size(buf)) are thrown as runtime errors as per die(). + # Returns the number of bytes successfully read. + read:func(filehandle,buf,length) + { + return nasal_call_builtin_c_read(filehandle,buf,length); + }, + # Attempts to write the entirety of the specified string to the filehandle. + # Failures are thrown as runtime errors as per die(). + # Returns the number of bytes successfully written. + write:func(filehandle,str) + { + return nasal_call_builtin_c_write(filehandle,str); + }, + # As ANSI fseek(). + # Attempts to seek to the specified position based on the whence value + # (which must be one of io.SEEK_SET,io.SEEK_END, or io.SEEK_CUR) + SEEK_SET:1, + SEEK_CUR:2, + SEEK_END:3, + seek:func(filehandle,position,whence) + { + nasal_call_builtin_c_seek(filehandle,position,whence); + return; + }, + # Returns the current seek position of the filehandle. + tell:func(filehandle) + { + return nasal_call_builtin_c_tell(filehandle); + }, + # Reads and returns a single text line from the filehandle. + # Interprets both "\n" and "\r\n" as end of line markers, + # and does not include the "\r" or "\n" bytes in the returned string. + # End offile or error is signaled by returning nil. + readln:func(filehandle) + { + return nasal_call_builtin_builtin_c_getline(filehandle); + }, + # Calls unix or win32 stat() on the specified file name and + # returns a seven element array whose contents are, + # in order: dev, ino, mode,nlink, uid, gid, rdef, size, atime, mtime, ctime. + # Errors are signaled as exceptions as per die(). + stat:func(filename) + { + return nasal_call_builtin_builtin_stat(filename); + }, +}; + +var print=func(dyn...) +{ + nasal_call_builtin_c_std_puts(dyn); + return nil; +}; \ No newline at end of file diff --git a/version3.0/lib/math.nas b/version3.0/lib/math.nas new file mode 100644 index 0000000..1bbafa4 --- /dev/null +++ b/version3.0/lib/math.nas @@ -0,0 +1,49 @@ +# nasal lib math.nas +# 2020/2/8 +# this file is used to avoid name confliction +# and is used to avoid name undefined +# before running this file will be translated to abstract syntax tree +# and this ast will be linked before main ast as main-ast's beginning + +var math= +{ + # Euler's constant + e:2.7182818284590452354, + pi:3.14159265358979323846, + # Returns the sine of the single argument + sin:func(x) + { + return nasal_call_builtin_sin(x); + }, + # Returns the cosine of the single argument + cos:func(x) + { + return nasal_call_builtin_cos(x); + }, + # you know what the f*ck this is + tan:func(x) + { + return nasal_call_builtin_tan(x); + }, + # Returns e (Euler's constant) raised to the power specified by the single argument + exp:func(x) + { + return nasal_call_builtin_exp(x); + }, + # Returns the natural logarithm of the single argument. + ln:func(x) + { + return nasal_call_builtin_cpp_math_ln(x); + }, + # Returns the square root of the single argument. + sqrt:func(x) + { + return nasal_call_builtin_cpp_math_sqrt(x); + }, + # Returns the arctangent of y/x, with the correct sign for the quadrant. + # Wraps the ANSI C function of the same name. + atan2:func(x,y) + { + return nasal_call_builtin_cpp_atan2(x,y); + }, +}; \ No newline at end of file diff --git a/version3.0/lib/readline.nas b/version3.0/lib/readline.nas new file mode 100644 index 0000000..875d086 --- /dev/null +++ b/version3.0/lib/readline.nas @@ -0,0 +1,12 @@ +# nasal lib readline.nas +# 2020/2/6 +# this file is used to avoid name confliction +# and is used to avoid name undefined +# before running this file will be translated to abstract syntax tree +# and this ast will be linked before main ast as main-ast's beginning + +# GNU Readline Library +var readline=func(prompt="> ") +{ + return; +} \ No newline at end of file diff --git a/version3.0/lib/regex.nas b/version3.0/lib/regex.nas new file mode 100644 index 0000000..f7642fd --- /dev/null +++ b/version3.0/lib/regex.nas @@ -0,0 +1,12 @@ +# nasal lib regex.nas +# 2020/2/6 +# this file is used to avoid name confliction +# and is used to avoid name undefined +# before running this file will be translated to abstract syntax tree +# and this ast will be linked before main ast as main-ast's beginning + +var regex= +{ + comp:func(){}, + exec:func(){}, +}; \ No newline at end of file diff --git a/version3.0/lib/sqlite.nas b/version3.0/lib/sqlite.nas new file mode 100644 index 0000000..838e612 --- /dev/null +++ b/version3.0/lib/sqlite.nas @@ -0,0 +1,15 @@ +# nasal lib sqlite.nas +# 2020/2/6 +# this file is used to avoid name confliction +# and is used to avoid name undefined +# before running this file will be translated to abstract syntax tree +# and this ast will be linked before main ast as main-ast's beginning + +var sqlite= +{ + open:func(){}, + close:func(){}, + prepare:func(){}, + exec:func(){}, + finalize:func(){}, +}; \ No newline at end of file diff --git a/version3.0/lib/system.nas b/version3.0/lib/system.nas new file mode 100644 index 0000000..9816478 --- /dev/null +++ b/version3.0/lib/system.nas @@ -0,0 +1,9 @@ +var system= +{ + # print the type of thing on the screen + type:func(thing) + { + nasal_call_builtin_scalar_type(thing); + return; + } +}; \ No newline at end of file diff --git a/version3.0/lib/thread.nas b/version3.0/lib/thread.nas new file mode 100644 index 0000000..1cb52f9 --- /dev/null +++ b/version3.0/lib/thread.nas @@ -0,0 +1,17 @@ +# nasal lib thread.nas +# 2020/2/6 +# this file is used to avoid name confliction +# and is used to avoid name undefined +# before running this file will be translated to abstract syntax tree +# and this ast will be linked before main ast as main-ast's beginning + +var thread= +{ + newthread:func(){}, + newlock:func(){}, + lock:func(){}, + unlock:func(){}, + newsem:func(){}, + semdown:func(){}, + semup:func(){}, +}; \ No newline at end of file diff --git a/version3.0/lib/unix.nas b/version3.0/lib/unix.nas new file mode 100644 index 0000000..6237a2c --- /dev/null +++ b/version3.0/lib/unix.nas @@ -0,0 +1,22 @@ +# nasal lib unix.nas +# 2020/2/6 +# this file is used to avoid name confliction +# and is used to avoid name undefined +# before running this file will be translated to abstract syntax tree +# and this ast will be linked before main ast as main-ast's beginning + +var unix= +{ + pipe:func(){}, + fork:func(){}, + dup2:func(){}, + exec:func(){}, + waitpid:func(){}, + opendir:func(){}, + readdir:func(){}, + closedir:func(){}, + time:func(){}, + chdir:func(){}, + environ:func(){}, + sleep:func(){}, +}; \ No newline at end of file diff --git a/version3.0/lib/utf8.nas b/version3.0/lib/utf8.nas new file mode 100644 index 0000000..1bd2e82 --- /dev/null +++ b/version3.0/lib/utf8.nas @@ -0,0 +1,15 @@ +# nasal lib utf8.nas +# 2020/2/6 +# this file is used to avoid name confliction +# and is used to avoid name undefined +# before running this file will be translated to abstract syntax tree +# and this ast will be linked before main ast as main-ast's beginning + +var utf8= +{ + chstr:func(){}, + strc:func(){}, + substr:func(){}, + size:func(){}, + validate:func(){}, +}; \ No newline at end of file diff --git a/version3.0/main.cpp b/version3.0/main.cpp new file mode 100644 index 0000000..1964486 --- /dev/null +++ b/version3.0/main.cpp @@ -0,0 +1,99 @@ +#include "nasal.h" + +void logo() +{ + std::cout<<" __ _ "<> [system] Windows system."<> [system] Linux system."<> [system] MacOS system."<> Nasal interpreter ver 3.0 ."<> Code: https://github.com/ValKmjolnir/Nasal-Interpreter"<> More info: http://wiki.flightgear.org/Nasal_scripting_language"<> Input \"help\" to get help ."<> "; + std::cin>>command; + if(command=="help") + { + std::cout<<">> [\'file\'] input a file."<> [cls ] clear the screen."<> [del ] clear the resource code."<> [lib ] add lib file."<> [rs ] print resource code."<> [lex ] turn code into tokens."<> [par ] turn tokens into abstract syntax tree."<> [ast ] check the abstract syntax tree."<> [run ] run code."<> [logo ] print logo of nasal ."<> [exit ] quit nasal interpreter."<> [Delete] complete."< +#include +#include +#include +#include +#include +/* if thread is used, don't forget to add -std=c++11 or higher standard before executing */ +// #include +#include +#include +#include +#include +#include + +#include "nasal_enum.h" +#include "nasal_resource.h" +#include "nasal_lexer.h" + +#endif \ No newline at end of file diff --git a/version3.0/nasal_enum.h b/version3.0/nasal_enum.h new file mode 100644 index 0000000..a0e13d6 --- /dev/null +++ b/version3.0/nasal_enum.h @@ -0,0 +1,21 @@ +#ifndef __NASAL_ENUM_H__ +#define __NASAL_ENUM_H__ + +/* token_type is used in lexer */ +enum token_type +{ + tok_null=0, + tok_number,tok_string, + tok_for,tok_forindex,tok_foreach,tok_while, + tok_var,tok_func,tok_break,tok_continue, + tok_return,tok_if,tok_elsif,tok_else,tok_nil, + tok_left_curve,tok_right_curve, + tok_left_bracket,tok_right_bracket, + tok_left_brace,tok_right_brace, + tok_semi,tok_and,tok_or,tok_comma,tok_dot,tok_ellipsis,tok_quesmark, + tok_colon,tok_add,tok_sub,tok_mult,tok_div,tok_link,tok_not, + tok_add_equal,tok_sub_equal,tok_mult_equal,tok_div_equal,tok_link_equal, + tok_cmp_equal,tok_cmp_not_equal,tok_less_than,tok_greater_than,tok_less_equal,tok_greater_equal +}; + +#endif \ No newline at end of file diff --git a/version3.0/nasal_lexer.h b/version3.0/nasal_lexer.h new file mode 100644 index 0000000..6fda5ae --- /dev/null +++ b/version3.0/nasal_lexer.h @@ -0,0 +1,99 @@ +#ifndef __NASAL_LEXER_H__ +#define __NASAL_LEXER_H__ + +#define IS_IDENTIFIER_HEAD(c) (c=='_')||('a'<=c && c<='z')||('A'<=c&&c<='Z') +#define IS_IDENTIFIER_BODY(c) (c=='_')||('a'<=c && c<='z')||('A'<=c&&c<='Z')||('0'<=c&&c<='9') +#define IS_NUMBER_HEAD(c) ('0'<=c&&c<='9') +#define IS_NUMBER_BODY(c) ('0'<=c&&c<='9')||('a'<=c&&c<='f')||('A'<=c&&c<='F')||(c=='e'||c=='E'||c=='.'||c=='x'||c=='o') +#define IS_STRING_HEAD(c) (c=='\''||c=='\"') +// single operators have only one character +#define IS_SINGLE_OPRATOR(c) (c=='('||c==')'||c=='['||c==']'||c=='{'||c=='}'||c==','||c==';'||c=='|'||c==':'||\ + c=='?'||c=='`'||c=='&'||c=='@'||c=='%'||c=='$'||c=='^'||c=='\\') +#define IS_DOT(c) (c=='.') +// calculation operators may have two chars, for example: += -= *= /= ~= != == >= <= +#define IS_CALC_OPERATOR(c) (c=='='||c=='+'||c=='-'||c=='*'||c=='!'||c=='/'||c=='<'||c=='>'||c=='~') +#define IS_NOTE_HEAD(c) (c=='#') + +#ifndef TOKEN_TABLE_SIZE +#define TOKEN_TABLE_SIZE 44 +struct token_table +{ + std::string str; + int tok_type; +}tok_tbl[TOKEN_TABLE_SIZE]= +{ + {"for" ,tok_for }, + {"forindex",tok_forindex }, + {"foreach" ,tok_foreach }, + {"while" ,tok_while }, + {"var" ,tok_var }, + {"func" ,tok_func }, + {"break" ,tok_break }, + {"continue",tok_continue }, + {"return" ,tok_return }, + {"if" ,tok_if }, + {"elsif" ,tok_elsif }, + {"else" ,tok_else }, + {"nil" ,tok_nil }, + {"(" ,tok_left_curve }, + {")" ,tok_right_curve }, + {"[" ,tok_left_bracket }, + {"]" ,tok_right_bracket}, + {"{" ,tok_left_brace }, + {"}" ,tok_right_brace }, + {";" ,tok_semi }, + {"and" ,tok_and }, + {"or" ,tok_or }, + {"," ,tok_comma }, + {"." ,tok_dot }, + {"..." ,tok_ellipsis }, + {"?" ,tok_quesmark }, + {":" ,tok_colon }, + {"+" ,tok_add }, + {"-" ,tok_sub }, + {"*" ,tok_mult }, + {"/" ,tok_div }, + {"~" ,tok_link }, + {"!" ,tok_not }, + {"+=" ,tok_add_equal }, + {"-=" ,tok_sub_equal }, + {"*=" ,tok_mult_equal }, + {"/=" ,tok_div_equal }, + {"~=" ,tok_link_equal }, + {"==" ,tok_cmp_equal }, + {"!=" ,tok_cmp_not_equal}, + {"<" ,tok_less_than }, + {">" ,tok_greater_than }, + {"<=" ,tok_less_equal }, + {">=" ,tok_greater_equal}, +}; +#endif + +struct token +{ + int line; + int type; + std::string str; +}; + +class nasal_lexer +{ +private: + std::vector token_list; +public: + void delete_tokens(); + void scanner(std::vector&); +}; + +void nasal_lexer::delete_tokens() +{ + token_list.clear(); + return; +} + +void nasal_lexer::scanner(std::vector& res) +{ + return; +} + +#endif \ No newline at end of file diff --git a/version3.0/nasal_resource.h b/version3.0/nasal_resource.h new file mode 100644 index 0000000..b9535e0 --- /dev/null +++ b/version3.0/nasal_resource.h @@ -0,0 +1,97 @@ +#ifndef __NASAL_RESOURCE_H__ +#define __NASAL_RESOURCE_H__ + +/* filenames of lib files */ +#ifndef LIB_FILE_NUM +#define LIB_FILE_NUM 11 +const std::string lib_filename[LIB_FILE_NUM]= +{ + "lib/base.nas", + "lib/bits.nas", + "lib/io.nas", + "lib/math.nas", + "lib/readline.nas", + "lib/regex.nas", + "lib/sqlite.nas", + "lib/system.nas", + "lib/thread.nas", + "lib/unix.nas", + "lib/utf8.nas" +}; +#endif + +class nasal_resource +{ +private: + std::vector res; +public: + void input_file(std::string); + void load_lib(); + void delete_file(); + void print_file(); + std::vector& get_file(); +}; + +void nasal_resource::input_file(std::string filename) +{ + std::ifstream fin(filename,std::ios::binary); + if(fin.fail()) + { + std::cout<<">> [resource] cannot open file \'"<input_file(lib_filename[i]); + return; +} + +void nasal_resource::delete_file() +{ + res.clear(); + return; +} + +void nasal_resource::print_file() +{ + int size=res.size(),line=1; + std::cout<=0 && unicode_str.length()) + { + std::cout<& nasal_resource::get_file() +{ + return res; +} + +#endif \ No newline at end of file