Start writing the REPL in Wren.

It doesn't actually execute code yet, but it:

- Supports left and right arrow keys for moving the cursor.
- Ctrl-C, Ctrl-D, Ctrl-A, and Ctrl-E for navigating.
- Syntax highlights the line (!).

The next step is to do a rough parse so that we can tell if the line
is an expression, statement, or needs more input. That will tell us
whether we need to interpret it at the top level (statement) and not
worry about a result, evaluate it as an expression and print the result,
or read more lines.
This commit is contained in:
Bob Nystrom
2016-05-20 20:30:09 -07:00
parent 59e9eb127e
commit 689cd42269
7 changed files with 1370 additions and 19 deletions

View File

@ -18,6 +18,10 @@
29205C9D1AB4E6430073018D /* wren_utils.c in Sources */ = {isa = PBXBuildFile; fileRef = 29205C961AB4E6430073018D /* wren_utils.c */; };
29205C9E1AB4E6430073018D /* wren_value.c in Sources */ = {isa = PBXBuildFile; fileRef = 29205C971AB4E6430073018D /* wren_value.c */; };
29205C9F1AB4E6430073018D /* wren_vm.c in Sources */ = {isa = PBXBuildFile; fileRef = 29205C981AB4E6430073018D /* wren_vm.c */; };
293B25571CEFD8C7005D9537 /* repl.c in Sources */ = {isa = PBXBuildFile; fileRef = 293B25541CEFD8C7005D9537 /* repl.c */; };
293B25581CEFD8C7005D9537 /* repl.c in Sources */ = {isa = PBXBuildFile; fileRef = 293B25541CEFD8C7005D9537 /* repl.c */; };
293B25591CEFD8C7005D9537 /* repl.wren.inc in Sources */ = {isa = PBXBuildFile; fileRef = 293B25561CEFD8C7005D9537 /* repl.wren.inc */; };
293B255A1CEFD8C7005D9537 /* repl.wren.inc in Sources */ = {isa = PBXBuildFile; fileRef = 293B25561CEFD8C7005D9537 /* repl.wren.inc */; };
293D46961BB43F9900200083 /* call.c in Sources */ = {isa = PBXBuildFile; fileRef = 293D46941BB43F9900200083 /* call.c */; };
2949AA8D1C2F14F000B106BA /* get_variable.c in Sources */ = {isa = PBXBuildFile; fileRef = 2949AA8B1C2F14F000B106BA /* get_variable.c */; };
29512C811B91F8EB008C10E6 /* libuv.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 29512C801B91F8EB008C10E6 /* libuv.a */; };
@ -103,6 +107,9 @@
29205CA61AB4E65E0073018D /* wren_utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wren_utils.h; path = ../../src/vm/wren_utils.h; sourceTree = "<group>"; };
29205CA71AB4E65E0073018D /* wren_value.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wren_value.h; path = ../../src/vm/wren_value.h; sourceTree = "<group>"; };
29205CA81AB4E65E0073018D /* wren_vm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wren_vm.h; path = ../../src/vm/wren_vm.h; sourceTree = "<group>"; };
293B25541CEFD8C7005D9537 /* repl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = repl.c; path = ../../src/module/repl.c; sourceTree = "<group>"; };
293B25551CEFD8C7005D9537 /* repl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = repl.h; path = ../../src/module/repl.h; sourceTree = "<group>"; };
293B25561CEFD8C7005D9537 /* repl.wren.inc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = repl.wren.inc; path = ../../src/module/repl.wren.inc; sourceTree = "<group>"; };
293D46941BB43F9900200083 /* call.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = call.c; path = ../../test/api/call.c; sourceTree = "<group>"; };
293D46951BB43F9900200083 /* call.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = call.h; path = ../../test/api/call.h; sourceTree = "<group>"; };
2949AA8B1C2F14F000B106BA /* get_variable.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = get_variable.c; path = ../../test/api/get_variable.c; sourceTree = "<group>"; };
@ -173,6 +180,9 @@
29D025E11C19CD1000A3BB28 /* os.h */,
29D025E01C19CD1000A3BB28 /* os.c */,
29D025E21C19CD1000A3BB28 /* os.wren.inc */,
293B25551CEFD8C7005D9537 /* repl.h */,
293B25541CEFD8C7005D9537 /* repl.c */,
293B25561CEFD8C7005D9537 /* repl.wren.inc */,
291647C31BA5EA45006142EE /* scheduler.h */,
291647C21BA5EA45006142EE /* scheduler.c */,
291647CD1BA5ED26006142EE /* scheduler.wren.inc */,
@ -373,9 +383,11 @@
291647C41BA5EA45006142EE /* scheduler.c in Sources */,
29A427341BDBE435001E6E22 /* wren_opt_meta.c in Sources */,
29205C9B1AB4E6430073018D /* wren_debug.c in Sources */,
293B25591CEFD8C7005D9537 /* repl.wren.inc in Sources */,
29205C9D1AB4E6430073018D /* wren_utils.c in Sources */,
29D025E51C19CD1000A3BB28 /* os.wren.inc in Sources */,
29D025E31C19CD1000A3BB28 /* os.c in Sources */,
293B25571CEFD8C7005D9537 /* repl.c in Sources */,
29729F311BA70A620099CA20 /* io.c in Sources */,
29A427361BDBE435001E6E22 /* wren_opt_meta.wren.inc in Sources */,
29205C9E1AB4E6430073018D /* wren_value.c in Sources */,
@ -397,6 +409,7 @@
2949AA8D1C2F14F000B106BA /* get_variable.c in Sources */,
29DC14A11BBA2FEC008A8274 /* scheduler.c in Sources */,
29A427391BDBE435001E6E22 /* wren_opt_random.c in Sources */,
293B255A1CEFD8C7005D9537 /* repl.wren.inc in Sources */,
29932D511C20D8C900099DEE /* benchmark.c in Sources */,
29DC14A01BBA2FD6008A8274 /* timer.c in Sources */,
29DC149F1BBA2FCC008A8274 /* vm.c in Sources */,