Commit Graph

416 Commits

Author SHA1 Message Date
Stephen Chung
5f12391ec6 Use hashed lookup for module-qualified functions and variables. 2020-05-08 00:19:08 +08:00
Stephen Chung
f3c0609377 Catch more assignment errors at parse time. 2020-05-07 12:25:09 +08:00
Stephen Chung
e966f5d49e Fix bug with let statement without expression. 2020-05-06 22:54:34 +08:00
Stephen Chung
d75a8bc6cd Make sure all features compile correctly. 2020-05-06 19:45:17 +08:00
Stephen Chung
88fec57394 Make module_resolver optional and remove NullModuleResolver. 2020-05-06 16:09:44 +08:00
Stephen Chung
aae9e43109 Implement module-qualified functions. 2020-05-05 17:51:40 +08:00
Stephen Chung
38e717a838 Build Module type plus engine hooks. 2020-05-05 15:00:10 +08:00
Stephen Chung
c03b162b7e Refactor code base and split into more module files. 2020-05-05 12:24:13 +08:00
Stephen Chung
143861747d Rename sub-scope/SubScope to module. 2020-05-05 10:39:12 +08:00
Stephen Chung
64036f69ca Refine modules. 2020-05-04 23:07:42 +08:00
Stephen Chung
2bdd174f16 Add import statement. 2020-05-04 19:36:58 +08:00
Stephen Chung
ead9716f6d Add namespacing syntax. 2020-05-04 17:43:54 +08:00
jhwgh1968
7011e4068f Start on namespaces 2020-05-03 12:19:01 -05:00
Stephen Chung
d83b829810 Avoid copying arguments for function calls. 2020-05-03 16:54:24 +08:00
Stephen Chung
c7c7fe3dfc Reduce size of Expr and Stmt by Boxing strings. 2020-05-01 17:32:39 +08:00
Stephen Chung
21c3edb31e Streamline. 2020-04-29 16:11:54 +08:00
Stephen Chung
304c658f89 Use scope offset for variable access. 2020-04-28 23:05:03 +08:00
Stephen Chung
9ad9dd52ab Reduce unnecessary Cow's in Expr. 2020-04-28 19:39:36 +08:00
Stephen Chung
f5c7d7cd0d Reduce memory footprint of Target. 2020-04-26 19:37:32 +08:00
Stephen Chung
33d3e34908 Deep linking for dot/index chains. 2020-04-26 18:04:07 +08:00
Stephen Chung
5aaaa7be3b Simplify parsing by expecting the tokens stream will never be exhausted. 2020-04-23 13:24:24 +08:00
Stephen Chung
fbfea60903 Disallow assignments in expressions. 2020-04-22 17:37:06 +08:00
Stephen Chung
c69647d9fd Change Dynamic::from_xxx to From<xxx> impl. 2020-04-22 12:12:13 +08:00
Stephen Chung
69733688bf Make all public API's return Box<EvalAltResult> to reduce footprint. 2020-04-21 23:25:12 +08:00
Stephen Chung
0306d15c04 Split core and standard libraries into packages. 2020-04-21 00:11:25 +08:00
Stephen Chung
a0bc49c867 Reduce size of Dynamic by boxing large types. 2020-04-18 11:10:03 +08:00
Stephen Chung
f5fff828e8 Box errors to reduce return type footprint. 2020-04-18 00:14:33 +08:00
Stephen Chung
65d611b976 FIX: no_float errors. 2020-04-17 20:08:41 +08:00
Stephen Chung
c5f66e932b Simplify parsing by introducing an EOF token. 2020-04-17 20:01:41 +08:00
Stephen Chung
5d9a99cefc Refine postfix operators handling. 2020-04-17 19:00:52 +08:00
Stephen Chung
3a93ab8240 Make FunctionsLib a HashMap. 2020-04-16 23:58:57 +08:00
Stephen Chung
f8e9d66a0b Remove lifetime from Engine. 2020-04-16 23:31:48 +08:00
Stephen Chung
a35518fe49 Split tokenizer into separate file, plus fix no_std feature. 2020-04-15 22:21:23 +08:00
Stephen Chung
78cd53db09 Streamline tokens reading and reformat code for easier reading. 2020-04-15 21:41:28 +08:00
Stephen Chung
5152a40e93 Change Dynamic to enum. 2020-04-12 23:00:06 +08:00
Stephen Chung
bc0d43d68f Simplify code. 2020-04-11 18:09:03 +08:00
Stephen Chung
d73cfb6da5 Allow escaping quotes in strings. 2020-04-11 12:46:10 +08:00
Stephen Chung
4b2cff715e Optimize property access for object maps. 2020-04-10 21:02:13 +08:00
Stephen Chung
ff8eca8a5e Add parse_json. 2020-04-10 17:14:07 +08:00
Stephen Chung
adbfceb5be Do not omit error enum variants. 2020-04-10 12:16:39 +08:00
Stephen Chung
bcff6bfd71 Remove no_stdlib feature in favor of Engine::new_raw(). 2020-04-08 10:19:03 +08:00
Stephen Chung
e0bb2e5c97 Change optimize_ast to take optimization level as parameter. 2020-04-08 09:30:50 +08:00
Stephen Chung
e795a50ae2 Make Engine reentrant to prepare for parallel execution. 2020-04-07 13:23:06 +08:00
Stephen Chung
e204ae1a2c Add 'in' expression. 2020-04-06 17:47:34 +08:00
Stephen Chung
32672b184b Avoid copying strings. 2020-04-06 12:29:01 +08:00
Stephen Chung
44d6a5e466 Reduce cloning. 2020-04-05 17:44:48 +08:00
Stephen Chung
e0514a4ec0 Remove ref modifiers. 2020-04-05 12:37:07 +08:00
Stephen Chung
29150faef2 Improve AST evaluation efficiency by sharing functions. 2020-04-04 22:00:44 +08:00
Stephen Chung
92b549b828 Add features info in docs. 2020-04-03 19:42:01 +08:00
Stephen Chung
5e7c9b47d5 Rename downcast to try_cast and add cast for Dynamic. 2020-04-02 12:35:44 +08:00
Stephen Chung
4ea2fb88ae Add continue statement. 2020-04-01 16:22:18 +08:00
Stephen Chung
246a865abd Fix doc test. 2020-04-01 10:21:49 +08:00
Stephen Chung
01c0b51017 Change object maps to #{ ... } 2020-03-30 17:40:26 +08:00
Stephen Chung
fce51758d1 Add support for string literal property names in object maps. 2020-03-30 12:14:59 +08:00
Stephen Chung
45ee51874f Add object maps. 2020-03-29 23:53:35 +08:00
Stephen Chung
ef6c6ea6d2 Add no_object feature to disable objects. 2020-03-29 17:15:12 +08:00
Stephen Chung
a8a4ed2967 Merge all MissingXXX errors into MissingToken. 2020-03-29 13:44:27 +08:00
Stephen Chung
ef6dd9414a Allow if expressions. 2020-03-27 23:47:23 +08:00
Stephen Chung
796690f506 Detect duplicated parameters in function definitions. 2020-03-27 16:46:08 +08:00
Stephen Chung
cc8554d095 Add merge/+ to AST. 2020-03-27 11:50:24 +08:00
Stephen Chung
56df5c49c8 Encapsulate FunctionsLib to hold script-defined functions. 2020-03-26 20:26:05 +08:00
Stephen Chung
5aea997672 Refine Scope API. 2020-03-25 11:27:18 +08:00
Stephen Chung
3ea482567f Simplify code style. 2020-03-24 16:46:47 +08:00
Stephen Chung
156ebd7ea4 Avoid copying tokens. 2020-03-24 11:21:20 +08:00
Stephen Chung
3677bd3651 Make Token smaller by boxing LexError. 2020-03-24 09:49:37 +08:00
Stephen Chung
1b4bcbcfdf Add evaluate expressions. 2020-03-22 21:03:58 +08:00
Stephen Chung
b6320c0eef Minor fine tuning. 2020-03-22 10:18:16 +08:00
Stephen Chung
1d98f65342 Disallow statement expressions in if and while guards to reduce code confusion. 2020-03-20 19:50:58 +08:00
Stephen Chung
6a6c5f30de Add eval function. 2020-03-19 19:53:42 +08:00
Stephen Chung
b3efb8b264 Disallow variable names starting with _ + digit. 2020-03-18 23:09:53 +08:00
Stephen Chung
019e73bc7e Allow empty statements. 2020-03-18 18:41:18 +08:00
Stephen Chung
ca20faf170 Add code comments. 2020-03-18 10:43:59 +08:00
Stephen Chung
8efe080412 Handle break and return better. 2020-03-18 10:42:27 +08:00
Stephen Chung
b26ca753c2 Mandatory semiclolons separating statements. 2020-03-18 10:40:07 +08:00
Stephen Chung
abe5365bfd Improve error messages to lists. 2020-03-18 10:40:07 +08:00
Trangar
c8a9df0a0a Added no_std support 2020-03-17 19:26:11 +01:00
Stephen Chung
2c90fea764 Catch illegal variable names. 2020-03-16 12:38:01 +08:00
Stephen Chung
372321dfe3 Add full optimization level for aggressive optimizing. 2020-03-15 22:39:58 +08:00
Stephen Chung
01cf777961 Use matches! macro. 2020-03-14 23:41:15 +08:00
Stephen Chung
973153e832 Add no_optimize feature to disable optimizations. 2020-03-14 20:06:10 +08:00
Stephen Chung
26bdc8ba08 FIX - fixes panic when constant array is assigned to. Refine README section on constants. 2020-03-14 19:46:44 +08:00
Stephen Chung
504fd56f1f More documentation on chained assignment. 2020-03-14 14:57:59 +08:00
Stephen Chung
360fab7760 Merge branch 'chained-assignments' 2020-03-14 14:41:48 +08:00
Stephen Chung
b3a22d942a Allow AST optimization based on external Scope. 2020-03-14 14:30:44 +08:00
Stephen Chung
d5adee2209 Allow chained assignments. 2020-03-14 11:51:45 +08:00
Stephen Chung
9844ae8665 Add constants. 2020-03-13 18:12:41 +08:00
Stephen Chung
9bd66c7db3 Minor improvements to the optimizer. 2020-03-12 23:46:52 +08:00
Stephen Chung
560da5fdc6 Allow call_fn with only one parameter; consume can retain functions, eval cannot. 2020-03-12 14:54:14 +08:00
Stephen Chung
e24d3a7ade Allow overloading of script functions. 2020-03-12 13:02:13 +08:00
Stephen Chung
1765d302b9 Minor refactor. 2020-03-12 12:40:28 +08:00
Stephen Chung
952932f64c Reduce cloning. 2020-03-11 23:43:04 +08:00
Stephen Chung
7c4d22d98a Add no_function feature to disable script-defined functions. 2020-03-11 13:28:12 +08:00
Stephen Chung
880bce1114 General cleanup. 2020-03-11 11:03:18 +08:00
Stephen Chung
708c285a0a Add only_i32 and only_i64 features. 2020-03-10 23:06:20 +08:00
Stephen Chung
cc772c6e2a Add no_float feature to disable floating-point. 2020-03-10 18:32:01 +08:00
Stephen Chung
52b5732bcb Add no_inidex feature to disable arrays and indexing. 2020-03-10 17:10:33 +08:00
Stephen Chung
2d80ee2f18 Refine optimizer. 2020-03-10 11:22:41 +08:00
Stephen Chung
55e7af7b04 Add AST optimizer. 2020-03-09 21:57:07 +08:00
Stephen Chung
e54fb54da2 Catch indexing errors at compile time. 2020-03-09 10:41:17 +08:00
Stephen Chung
01d04f717b Natively handle negative numbers in tokenizer instead of the neg() function. 2020-03-09 10:10:19 +08:00
Stephen Chung
b1b25d3043 Add fallible functions support and replace most arithmetic operations with checked versions. 2020-03-08 22:47:13 +08:00
Stephen Chung
3e7adc2e51 More comments in code. 2020-03-08 19:54:02 +08:00
Stephen Chung
eed7bef974 Allow chaining of indexing (one level) and dotting. 2020-03-07 22:50:46 +08:00
Stephen Chung
df6950f8f7 Fix arrayindexed property access. 2020-03-07 20:55:03 +08:00
Stephen Chung
d055638e83 Properly detect invalid assignment LHS at compile time. 2020-03-07 17:32:15 +08:00
Stephen Chung
a8be700b9f Simplify op-assignment. 2020-03-07 13:39:28 +08:00
Stephen Chung
22cb69a16b Allow block expressions. 2020-03-07 10:39:00 +08:00
Stephen Chung
473e40e8a4 Catch more invalid LHS for assignments. 2020-03-07 10:16:20 +08:00
Stephen Chung
024133ae2d Avoid string copying. 2020-03-07 10:15:42 +08:00
Stephen Chung
07e396b3f5 Allow chaining of array indexing operations. 2020-03-06 10:50:52 +08:00
Stephen Chung
3d3b939ba6 Simplify code, document logic, refactor and better error messages. 2020-03-06 01:05:02 +08:00
Stephen Chung
883f08c026 Enable more indexing expressions. 2020-03-05 20:28:03 +08:00
Stephen Chung
ba2aac4960 General code cleanup. 2020-03-04 23:06:05 +08:00
Stephen Chung
bb56a7a843 Code refactor, bug fixes, code docs. 2020-03-04 22:00:01 +08:00
Stephen Chung
b4d56accd4 Reverse commit fa13588f69. Limit input script size not meaningful. 2020-03-04 09:33:35 +08:00
Stephen Chung
b421c8ac50 Minor refactor. 2020-03-03 23:31:29 +08:00
Stephen Chung
71a3c79915 Fix number parsing. 2020-03-03 21:39:25 +08:00
Stephen Chung
9f80bf03c4 Add throw. 2020-03-03 18:15:20 +08:00
Stephen Chung
95d0b2e620 Better error messages for function definitions. 2020-03-03 16:23:55 +08:00
Stephen Chung
fa13588f69 Limit script size to avoid overflowing positions. 2020-03-03 13:30:46 +08:00
Stephen Chung
0e96e1080c Comprehensive error line number/character position during evaluation. 2020-03-02 22:13:14 +08:00
Stephen Chung
ed8d2ac20f Add else if control flow. 2020-03-02 17:04:56 +08:00
Stephen Chung
a5e09295f8 Allow comparisons between different types (returning false). 2020-03-02 14:28:42 +08:00
Stephen Chung
22a505b57b Short-curcuit boolean operators. 2020-03-02 12:08:03 +08:00
Stephen Chung
e93fd7d3fe Properly handle char types. 2020-03-01 13:30:22 +08:00
Stephen Chung
5f135353c0 Change precedence to i8. 2020-02-29 21:18:48 +08:00
Stephen Chung
17f0001b11 Fix string handling - error for unterminated strings. 2020-02-29 21:10:31 +08:00
Stephen Chung
4b3cf95871 Simplify position handling. 2020-02-29 20:12:10 +08:00
Stephen Chung
c9daab3754 Simplify code by removing redirections. 2020-02-29 17:10:51 +08:00
Stephen Chung
e4e471fd20 Add line/position in compilation errors; Add compile to AST; FIx infinite loop in close parens. 2020-02-24 23:25:52 +08:00
Stephen Chung
157aa2be94 Add for statement and range function; New register_box_fn for functions returning Box<dyn Any> (which should not be boxed again); Register standard utility functions in library (e.g. print, string concat). 2020-02-23 22:48:46 +08:00
timfish
82fd20b2b1 Rust 2018 2019-09-18 11:21:07 +01:00
russ morris
2f46af64dd added unit type as () 2018-05-22 16:44:41 -07:00
Lukáš Hozda
b318ec24a9 rename OpEquals to OpAssign, as all of them are compound assignment operators 2017-12-21 12:32:18 +01:00
Lukáš Hozda
5edcfc2156 minor refactor 2017-12-21 12:28:59 +01:00
russ
3a5a1d2aff i64 and f64 exponent implementation 2017-11-23 23:56:22 -08:00
Lukáš Hozda
3c8feab630 allow unary after compound and new binary operators 2017-11-01 23:09:07 +01:00
russ
7f6edf732f resolved merge conflicts 2017-11-01 11:17:53 -07:00
russ
6d151bc2b9 minor refactor for sanity 2017-10-31 22:10:46 -07:00
russ
6cff70f2a3 binary, hex, octal literal types 2017-10-31 22:02:36 -07:00
russ
4fed05c20a bugfix for binary and, modulo, binary ops tests 2017-10-31 15:06:13 -07:00
russ
f1cd71a72b candidate compound assignment implementation 2017-10-30 22:55:20 -07:00
russ
e5e58fce98 sync'd latest master 2017-10-30 08:08:44 -07:00
russ
18c6892df3 take 2, 100% fewer variable name conflicts 2017-10-29 20:32:41 -07:00
russ
01666cefb9 candidate f64 support 2017-10-27 20:30:12 -07:00
Lukáš Hozda
00dedcc3b4 minor refactoring 2017-10-14 19:46:22 +02:00
Lukáš Hozda
a1e92d006c clippy refactoring 2017-10-02 23:44:45 +02:00
Lukáš Hozda
660fbe2e39 [BREAKING CHANGE] change variable keyword to 'let' from 'var' 2017-10-02 08:46:35 +02:00
Lukáš Hozda
87b68b79f8 check if a char is whitespace instead of explicitly checking against a few chars, ignore Cargo.lock 2017-10-02 08:33:47 +02:00
Jonathan Turner
2a28209b38 Add string concat/compare. Bump to 0.4 2016-08-17 18:33:31 -07:00
jonathandturner
7a46c7d9bc Refactoring a bit of the string/char parser code. Fmt'd 2016-04-16 19:32:18 -07:00
jonathandturner
b9ea072d6a Add support for character constants 2016-04-13 18:40:06 -07:00
jonathandturner
3364191781 Move to i64 by default 2016-04-13 18:05:44 -07:00
jonathandturner
4e38b9e611 Clean up trailing space and fix rhai_runner print out 2016-04-13 18:01:08 -07:00
jonathandturner
3dfc6e627d Move to using i64 by default 2016-04-12 19:52:27 -07:00
jonathandturner
b1ccaf4516 Add support for arrays 2016-03-26 10:46:28 -07:00
jonathandturner
254f4b081c Simplified function registration to not require explicit coercion step. Simplified eval to take &str instead of String 2016-03-16 18:07:08 -04:00
jonathandturner
72c23ad7ca Start adding support for dotted expressions 2016-03-07 15:39:02 -05:00
jonathandturner
b5075e6511 Fix divide support 2016-03-03 11:32:02 -05:00
jonathandturner
fbb5b72f24 Add support for loop breaks and function returns 2016-03-03 09:31:42 -05:00
jonathandturner
30b914e7b7 Add else to if 2016-03-03 08:20:55 -05:00
jonathandturner
0fd1af9c8d Improve lexer errors a little 2016-03-02 09:16:36 -05:00
jonathandturner
2bba8dc429 Add support for string constants with escape sequences 2016-03-02 08:37:28 -05:00
jonathandturner
a8fa76c2fc Support for methods. Started support for functions defined in script but not yet ready 2016-03-01 15:16:10 -05:00
jonathandturner
419781cfb6 Fill out support for operators 2016-03-01 09:40:48 -05:00
jonathandturner
6739706b64 Initial commit 2016-02-29 16:43:45 -05:00