Browse Source

Sol Part 61: It's Almost a Language Edition!

Happy 101st commit, Sol!
master
Graham Northup 5 years ago
parent
commit
2487f8762c
Signed by: grissess GPG Key ID: 5D000E6F539376FB
  1. 5
      .gitignore
  2. 7
      LICENSE
  3. 30
      Makefile
  4. 18
      sol.h
  5. 41
      sol_help.txt
  6. 14
      solrun.c
  7. 1
      state.c

5
.gitignore

@ -1,5 +1,5 @@
sol
solace
sol*
!sol_help.txt
*.o
stdout
.submodule_stamp
@ -13,3 +13,4 @@ iss*
_build
doxyxml
valgrind.log
*_INFO

7
LICENSE

@ -21,3 +21,10 @@ SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
The following exception is granted: these shall not be considered "derivative
works":
- source programs written in the Sol language;
- compiled programs encoded in the Sol bytecode, including those generated by
this program;
- the output generated as a direct result of executing a Sol program.

30
Makefile

@ -1,13 +1,24 @@
CFLAGS= -g
CFLAGS= -g $(BUILD_DEFINES)
LDFLAGS= -lm -ldl -lreadline
OBJ= lex.yy.o parser.tab.o dsl/seq.o dsl/list.o dsl/array.o dsl/generic.o astprint.o runtime.o gc.o object.o state.o builtins.o solrun.o ser.o
OBJ= lex.yy.o parser.tab.o dsl/seq.o dsl/list.o dsl/array.o dsl/generic.o astprint.o runtime.o gc.o object.o state.o builtins.o solrun.o ser.o sol_help.o
include VERSION_INFO
include ARCH_INFO
BUILD_DEFINES:= -DSOL_BUILD_HOST="\"$(shell uname -n)\"" -DSOL_BUILD_KERNEL="\"$(shell uname -s)\"" -DSOL_BUILD_ARCH="\"$(shell uname -m)\"" -DSOL_BUILD_REV="\"$(shell git rev-parse --short HEAD)$(shell git diff-index --quiet HEAD || echo '-dirty')\""
SOL_VER:=$(MAJOR).$(MINOR)$(RELEASE)$(PATCH)
LINKED_VERS:=sol sol$(MAJOR) sol$(MAJOR).$(MINOR)
.PHONY: all test
all: dsl sol
all: dsl $(LINKED_VERS)
$(LINKED_VERS): sol$(SOL_VER)
rm $@; ln -s $? $@
sol: $(OBJ)
gcc $(CFLAGS) $? $(LDFLAGS) -o sol
sol$(SOL_VER): $(OBJ)
gcc $(CFLAGS) $? $(LDFLAGS) -o $@
test: all $(sort $(patsubst tests/%.sol,test_%,$(wildcard tests/*.sol))) $(sort $(patsubst tests/%.sol,testcomp_%,$(wildcard tests/*.sol)))
@ -21,9 +32,18 @@ testcomp_%: tests/%.sol
dsl:
git submodule init && git submodule sync && git submodule update
VERSION_INFO: sol.h
perl -n -e '/#define SOL_VERSION "([[:digit:]]+)\.([[:digit:]]+)(.)([[:digit:]]+)"/ && print "MAJOR:=$$1\nMINOR:=$$2\nRELEASE:=$$3\nPATCH:=$$4\n"' $? > $@
ARCH_INFO: gc.o
objdump -f $? | perl -n -e '/file format ([^-]+-(.+))$$/ && print "HOST_ARCH:=$$2\nHOST_ELF:=$$1\n"' > $@
%.o: %.c
gcc -c -o $@ $? $(CFLAGS)
%.o: %.txt | ARCH_INFO
objcopy -B i386 -I binary -O $(HOST_ELF) $? $@
%.tab.c %.tab.h: %.y
bison -rall -fall -d $?

18
sol.h

@ -25,6 +25,24 @@
*/
#define SOL_HEXVER 0x0003A02
#ifndef SOL_BUILD_HOST
#define SOL_BUILD_HOST "(unknown host)"
#endif
#ifndef SOL_BUILD_KERNEL
#define SOL_BUILD_KERNEL "(unknown kernel)"
#endif
#ifndef SOL_BUILD_ARCH
#define SOL_BUILD_ARCH "(unknown arch)"
#endif
#ifndef SOL_BUILD_REV
#define SOL_BUILD_REV "(unknown rev)"
#endif
#define SOL_BUILD_ID "sol-" SOL_BUILD_REV " " __DATE__ " " __TIME__ " on " SOL_BUILD_HOST " " SOL_BUILD_KERNEL " " SOL_BUILD_ARCH
#ifndef SOL_ICACHE_MIN
/** The smallest integer to cache. */
#define SOL_ICACHE_MIN -128

41
sol_help.txt

@ -0,0 +1,41 @@
./sol [<options> [<arg> [<arg> ...]]]
Sol Executive - compiles and/or runs a Sol program.
Options given to Sol are given via the first argument. For options that take
parameters, they are read in the order specified in the option argument; e.g.,
"./sol ab a.foo b.bar" and "./sol ba b.bar a.foo" are equivalent, assuming
options "a" and "b" take arguments.
Sol currently recognizes the following options:
-d: Sets yydebug=1, which enables debug tracing of the parser/lexer.
-t: Prints the Sol syntax tree after program loading.
-i: Ignore any initialization files. By default, Sol executes any of these
files, if they exist and are readable, in the initial environment in this
order:
- /etc/sol/init.sol
- /opt/sol/init.sol
- $HOME/.config/sol/init.sol
These may be overridden during compilation.
-r <file>: Read the program from the file, instead of the default (stdin).
Programs run this way have access to stdin via `io.stdin` in the global
environment.
-c <file>: After loading the program, write bytecode to the file, instead of
running the program. Such files can be later loaded using the C option.
-C: Assume that the program file is a compiled bytecode stream instead of Sol
source text.
Sol's exit status is determined by the following, in this order:
- 0, on printing this help;
- 2, if an argument, parsing, or initialization error occurred;
- 0, if the file was to be compiled and was written successfully;
- 1, if the program in the file encountered an error at the top level;
- the integer value if an integer was returned at the top level;
- 0 otherwise.
For more information about the language itself, please refer to the source
repository and/or `make docs` therein.
Sol is Free Software under the Boost Software License, version 1.0; see LICENSE
in the source repository for more details.

14
solrun.c

@ -2,6 +2,8 @@
#include "ast.h"
#include "parser.tab.h"
extern char _binary_sol_help_txt_start, _binary_sol_help_txt_end;
int main(int argc, char **argv) {
stmt_node *program;
sol_state_t state;
@ -48,6 +50,18 @@ int main(int argc, char **argv) {
case 'C':
compiled = 1;
break;
case 'V':
printf(SOL_BUILD_ID "\n");
case 'h':
fwrite(
&_binary_sol_help_txt_start,
1,
&_binary_sol_help_txt_end - &_binary_sol_help_txt_start,
stdout
);
return 0;
break;
}
c++;
}

1
state.c

@ -470,7 +470,6 @@ int sol_state_init(sol_state_t *state) {
}
// Perform initialization based on the user profile, if so requested.
// TODO: Make this switchable at runtime.
if(!(state->features & SOL_FT_NO_USR_INIT)) {
for(i = 0; i < LENGTH(sol_AbsInitPaths); i++) {

Loading…
Cancel
Save