aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2021-07-08 00:14:31 -0700
committerGravatar Tom Willemse2021-07-08 02:25:13 -0700
commit68a2ebd34fc94488e89ffb82b359ec6e7e152ae9 (patch)
tree0dbbe26aff8fc38805b4b3780ae7842c433b9522
parent62bd0f83dc909547a69abb8b0aed40cf098b4c95 (diff)
downloadcrafting-interpreters-68a2ebd34fc94488e89ffb82b359ec6e7e152ae9.tar.gz
crafting-interpreters-68a2ebd34fc94488e89ffb82b359ec6e7e152ae9.zip
Restructure project to make room for clox
-rw-r--r--.gitignore2
-rw-r--r--Jenkinsfile4
-rwxr-xr-xjlox3
-rw-r--r--jlox/.gitignore (renamed from src/.gitignore)0
-rw-r--r--jlox/CMakeLists.txt (renamed from src/CMakeLists.txt)2
-rw-r--r--jlox/CMakePresets.json (renamed from src/CMakePresets.json)0
-rwxr-xr-xjlox/jlox3
-rw-r--r--jlox/src/com/craftinginterpreters/CMakeLists.txt (renamed from src/com/craftinginterpreters/CMakeLists.txt)0
-rw-r--r--jlox/src/com/craftinginterpreters/lox/.gitignore (renamed from src/com/craftinginterpreters/lox/.gitignore)0
-rw-r--r--jlox/src/com/craftinginterpreters/lox/.settings/org.eclipse.jdt.core.prefs2
-rw-r--r--jlox/src/com/craftinginterpreters/lox/AstPrinter.java (renamed from src/com/craftinginterpreters/lox/AstPrinter.java)0
-rw-r--r--jlox/src/com/craftinginterpreters/lox/CMakeLists.txt (renamed from src/com/craftinginterpreters/lox/CMakeLists.txt)0
-rw-r--r--jlox/src/com/craftinginterpreters/lox/Environment.java (renamed from src/com/craftinginterpreters/lox/Environment.java)0
-rw-r--r--jlox/src/com/craftinginterpreters/lox/Interpreter.java (renamed from src/com/craftinginterpreters/lox/Interpreter.java)0
-rw-r--r--jlox/src/com/craftinginterpreters/lox/Lox.java (renamed from src/com/craftinginterpreters/lox/Lox.java)0
-rw-r--r--jlox/src/com/craftinginterpreters/lox/LoxCallable.java (renamed from src/com/craftinginterpreters/lox/LoxCallable.java)0
-rw-r--r--jlox/src/com/craftinginterpreters/lox/LoxClass.java (renamed from src/com/craftinginterpreters/lox/LoxClass.java)0
-rw-r--r--jlox/src/com/craftinginterpreters/lox/LoxFunction.java (renamed from src/com/craftinginterpreters/lox/LoxFunction.java)0
-rw-r--r--jlox/src/com/craftinginterpreters/lox/LoxInstance.java (renamed from src/com/craftinginterpreters/lox/LoxInstance.java)0
-rw-r--r--jlox/src/com/craftinginterpreters/lox/Parser.java (renamed from src/com/craftinginterpreters/lox/Parser.java)0
-rw-r--r--jlox/src/com/craftinginterpreters/lox/Resolver.java (renamed from src/com/craftinginterpreters/lox/Resolver.java)0
-rw-r--r--jlox/src/com/craftinginterpreters/lox/Return.java (renamed from src/com/craftinginterpreters/lox/Return.java)0
-rw-r--r--jlox/src/com/craftinginterpreters/lox/RuntimeError.java (renamed from src/com/craftinginterpreters/lox/RuntimeError.java)0
-rw-r--r--jlox/src/com/craftinginterpreters/lox/Scanner.java (renamed from src/com/craftinginterpreters/lox/Scanner.java)0
-rw-r--r--jlox/src/com/craftinginterpreters/lox/Token.java (renamed from src/com/craftinginterpreters/lox/Token.java)0
-rw-r--r--jlox/src/com/craftinginterpreters/lox/TokenType.java (renamed from src/com/craftinginterpreters/lox/TokenType.java)0
-rw-r--r--jlox/src/com/craftinginterpreters/tool/CMakeLists.txt (renamed from src/com/craftinginterpreters/tool/CMakeLists.txt)0
-rw-r--r--jlox/src/com/craftinginterpreters/tool/GenerateAst.java (renamed from src/com/craftinginterpreters/tool/GenerateAst.java)0
-rw-r--r--src/fib.lox9
-rw-r--r--src/test.lox7
-rw-r--r--testsuite/jlox.tests/tests.exp2
31 files changed, 27 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f4b8e4b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+jlox.sum
+jlox.log
diff --git a/Jenkinsfile b/Jenkinsfile
index 24b123f..ef408d8 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -10,10 +10,10 @@ pipeline {
steps {
cmakeBuild installation: 'InSearchPath',
buildDir: 'build',
- sourceDir: 'src',
+ sourceDir: 'jlox',
steps: [[args: 'all']]
- archiveArtifacts artifacts: 'build/com/craftinginterpreters/lox/Lox.jar',
+ archiveArtifacts artifacts: 'jlox/_build/com/craftinginterpreters/lox/Lox.jar',
fingerprint: false,
onlyIfSuccessful: true
}
diff --git a/jlox b/jlox
deleted file mode 100755
index c6be2ea..0000000
--- a/jlox
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env sh
-
-/usr/bin/java -jar src/_build/com/craftinginterpreters/lox/Lox.jar "$@"
diff --git a/src/.gitignore b/jlox/.gitignore
index e35d885..e35d885 100644
--- a/src/.gitignore
+++ b/jlox/.gitignore
diff --git a/src/CMakeLists.txt b/jlox/CMakeLists.txt
index 52a7d57..da162c1 100644
--- a/src/CMakeLists.txt
+++ b/jlox/CMakeLists.txt
@@ -5,4 +5,4 @@ include(UseJava)
project(Lox NONE)
-add_subdirectory(com/craftinginterpreters)
+add_subdirectory(src/com/craftinginterpreters)
diff --git a/src/CMakePresets.json b/jlox/CMakePresets.json
index 728cdb0..728cdb0 100644
--- a/src/CMakePresets.json
+++ b/jlox/CMakePresets.json
diff --git a/jlox/jlox b/jlox/jlox
new file mode 100755
index 0000000..6798309
--- /dev/null
+++ b/jlox/jlox
@@ -0,0 +1,3 @@
+#!/usr/bin/env sh
+
+java -jar "$(dirname "$0")/_build/src/com/craftinginterpreters/lox/Lox.jar" "$@"
diff --git a/src/com/craftinginterpreters/CMakeLists.txt b/jlox/src/com/craftinginterpreters/CMakeLists.txt
index 959eedd..959eedd 100644
--- a/src/com/craftinginterpreters/CMakeLists.txt
+++ b/jlox/src/com/craftinginterpreters/CMakeLists.txt
diff --git a/src/com/craftinginterpreters/lox/.gitignore b/jlox/src/com/craftinginterpreters/lox/.gitignore
index 0260b11..0260b11 100644
--- a/src/com/craftinginterpreters/lox/.gitignore
+++ b/jlox/src/com/craftinginterpreters/lox/.gitignore
diff --git a/jlox/src/com/craftinginterpreters/lox/.settings/org.eclipse.jdt.core.prefs b/jlox/src/com/craftinginterpreters/lox/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..479bf4d
--- /dev/null
+++ b/jlox/src/com/craftinginterpreters/lox/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.formatter.lineSplit=80
diff --git a/src/com/craftinginterpreters/lox/AstPrinter.java b/jlox/src/com/craftinginterpreters/lox/AstPrinter.java
index 4c120d3..4c120d3 100644
--- a/src/com/craftinginterpreters/lox/AstPrinter.java
+++ b/jlox/src/com/craftinginterpreters/lox/AstPrinter.java
diff --git a/src/com/craftinginterpreters/lox/CMakeLists.txt b/jlox/src/com/craftinginterpreters/lox/CMakeLists.txt
index aeab240..aeab240 100644
--- a/src/com/craftinginterpreters/lox/CMakeLists.txt
+++ b/jlox/src/com/craftinginterpreters/lox/CMakeLists.txt
diff --git a/src/com/craftinginterpreters/lox/Environment.java b/jlox/src/com/craftinginterpreters/lox/Environment.java
index 407b9b3..407b9b3 100644
--- a/src/com/craftinginterpreters/lox/Environment.java
+++ b/jlox/src/com/craftinginterpreters/lox/Environment.java
diff --git a/src/com/craftinginterpreters/lox/Interpreter.java b/jlox/src/com/craftinginterpreters/lox/Interpreter.java
index 3f4d385..3f4d385 100644
--- a/src/com/craftinginterpreters/lox/Interpreter.java
+++ b/jlox/src/com/craftinginterpreters/lox/Interpreter.java
diff --git a/src/com/craftinginterpreters/lox/Lox.java b/jlox/src/com/craftinginterpreters/lox/Lox.java
index 6115f8f..6115f8f 100644
--- a/src/com/craftinginterpreters/lox/Lox.java
+++ b/jlox/src/com/craftinginterpreters/lox/Lox.java
diff --git a/src/com/craftinginterpreters/lox/LoxCallable.java b/jlox/src/com/craftinginterpreters/lox/LoxCallable.java
index 4204c20..4204c20 100644
--- a/src/com/craftinginterpreters/lox/LoxCallable.java
+++ b/jlox/src/com/craftinginterpreters/lox/LoxCallable.java
diff --git a/src/com/craftinginterpreters/lox/LoxClass.java b/jlox/src/com/craftinginterpreters/lox/LoxClass.java
index 5d1c136..5d1c136 100644
--- a/src/com/craftinginterpreters/lox/LoxClass.java
+++ b/jlox/src/com/craftinginterpreters/lox/LoxClass.java
diff --git a/src/com/craftinginterpreters/lox/LoxFunction.java b/jlox/src/com/craftinginterpreters/lox/LoxFunction.java
index 07dd727..07dd727 100644
--- a/src/com/craftinginterpreters/lox/LoxFunction.java
+++ b/jlox/src/com/craftinginterpreters/lox/LoxFunction.java
diff --git a/src/com/craftinginterpreters/lox/LoxInstance.java b/jlox/src/com/craftinginterpreters/lox/LoxInstance.java
index 64989e0..64989e0 100644
--- a/src/com/craftinginterpreters/lox/LoxInstance.java
+++ b/jlox/src/com/craftinginterpreters/lox/LoxInstance.java
diff --git a/src/com/craftinginterpreters/lox/Parser.java b/jlox/src/com/craftinginterpreters/lox/Parser.java
index ab4baaa..ab4baaa 100644
--- a/src/com/craftinginterpreters/lox/Parser.java
+++ b/jlox/src/com/craftinginterpreters/lox/Parser.java
diff --git a/src/com/craftinginterpreters/lox/Resolver.java b/jlox/src/com/craftinginterpreters/lox/Resolver.java
index fe3a641..fe3a641 100644
--- a/src/com/craftinginterpreters/lox/Resolver.java
+++ b/jlox/src/com/craftinginterpreters/lox/Resolver.java
diff --git a/src/com/craftinginterpreters/lox/Return.java b/jlox/src/com/craftinginterpreters/lox/Return.java
index 5bd62d0..5bd62d0 100644
--- a/src/com/craftinginterpreters/lox/Return.java
+++ b/jlox/src/com/craftinginterpreters/lox/Return.java
diff --git a/src/com/craftinginterpreters/lox/RuntimeError.java b/jlox/src/com/craftinginterpreters/lox/RuntimeError.java
index 017865b..017865b 100644
--- a/src/com/craftinginterpreters/lox/RuntimeError.java
+++ b/jlox/src/com/craftinginterpreters/lox/RuntimeError.java
diff --git a/src/com/craftinginterpreters/lox/Scanner.java b/jlox/src/com/craftinginterpreters/lox/Scanner.java
index e21f701..e21f701 100644
--- a/src/com/craftinginterpreters/lox/Scanner.java
+++ b/jlox/src/com/craftinginterpreters/lox/Scanner.java
diff --git a/src/com/craftinginterpreters/lox/Token.java b/jlox/src/com/craftinginterpreters/lox/Token.java
index 84762a4..84762a4 100644
--- a/src/com/craftinginterpreters/lox/Token.java
+++ b/jlox/src/com/craftinginterpreters/lox/Token.java
diff --git a/src/com/craftinginterpreters/lox/TokenType.java b/jlox/src/com/craftinginterpreters/lox/TokenType.java
index 9ab2a8b..9ab2a8b 100644
--- a/src/com/craftinginterpreters/lox/TokenType.java
+++ b/jlox/src/com/craftinginterpreters/lox/TokenType.java
diff --git a/src/com/craftinginterpreters/tool/CMakeLists.txt b/jlox/src/com/craftinginterpreters/tool/CMakeLists.txt
index b98d2eb..b98d2eb 100644
--- a/src/com/craftinginterpreters/tool/CMakeLists.txt
+++ b/jlox/src/com/craftinginterpreters/tool/CMakeLists.txt
diff --git a/src/com/craftinginterpreters/tool/GenerateAst.java b/jlox/src/com/craftinginterpreters/tool/GenerateAst.java
index 04b4500..04b4500 100644
--- a/src/com/craftinginterpreters/tool/GenerateAst.java
+++ b/jlox/src/com/craftinginterpreters/tool/GenerateAst.java
diff --git a/src/fib.lox b/src/fib.lox
new file mode 100644
index 0000000..dd6fb5e
--- /dev/null
+++ b/src/fib.lox
@@ -0,0 +1,9 @@
+fun fib(n) {
+ if (n < 2) return n;
+ return fib(n - 1) + fib(n - 2);
+}
+
+var before = clock();
+print fib(40);
+var after = clock();
+print after - before;
diff --git a/src/test.lox b/src/test.lox
new file mode 100644
index 0000000..8810767
--- /dev/null
+++ b/src/test.lox
@@ -0,0 +1,7 @@
+class Bacon {
+eat() {
+print "Crunch crunch crunch!";
+}
+}
+
+Bacon().eat();
diff --git a/testsuite/jlox.tests/tests.exp b/testsuite/jlox.tests/tests.exp
index 9b9f620..bd41cfb 100644
--- a/testsuite/jlox.tests/tests.exp
+++ b/testsuite/jlox.tests/tests.exp
@@ -1,5 +1,5 @@
set test_name "Printing"
-set command_line "./jlox"
+set command_line "jlox/jlox"
spawn $command_line
send "print \"Hello, world!\";\n"