rename to lr
This commit is contained in:
parent
2ed9bdf5c4
commit
98718e4e59
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -1,9 +1,9 @@
|
|||
*.o
|
||||
/par
|
||||
/libpar.a
|
||||
/lr
|
||||
/liblr.a
|
||||
/listing
|
||||
/version.h
|
||||
/completion/par
|
||||
/completion/lr
|
||||
/tests/*/bin*
|
||||
/.*.swp
|
||||
Session.vim
|
||||
|
|
64
Makefile
64
Makefile
|
@ -5,11 +5,11 @@ CFLAGS= -Wfatal-errors -Wall -Wextra -Werror=discarded-qualifiers -Werror=
|
|||
LDFLAGS= -g3 -no-pie -z noexecstack -lm -fsanitize=address -static-libasan
|
||||
ASFLAGS=
|
||||
OBJS= str.o tok.o vec.o lex.o pnode.o reg.o mem.o state.o err.o x86_64.o run.o ir.o gen.o i386.o sprint.o
|
||||
LIB= libpar.a
|
||||
TESTS_i386= $(notdir $(basename $(shell find tests/i386/ -name '*.par'))) $(notdir $(basename $(shell find tests/all/ -name '*.par')))
|
||||
TESTS_x86_64= $(notdir $(basename $(shell find tests/x86_64/ -name '*.par'))) $(notdir $(basename $(shell find tests/all/ -name '*.par')))
|
||||
LIB= liblr.a
|
||||
TESTS_i386= $(notdir $(basename $(shell find tests/i386/ -name '*.lr'))) $(notdir $(basename $(shell find tests/all/ -name '*.lr')))
|
||||
TESTS_x86_64= $(notdir $(basename $(shell find tests/x86_64/ -name '*.lr'))) $(notdir $(basename $(shell find tests/all/ -name '*.lr')))
|
||||
TESTS_CORE= $(notdir $(basename $(shell find tests/core/ -name '*.c')))
|
||||
PAR= ./par
|
||||
LR= ./lr
|
||||
#VALGRIND ?= valgrind --leak-check=full --log-file=$(@D)/valgrind.$*
|
||||
PREFIX ?= /usr/local
|
||||
|
||||
|
@ -17,16 +17,16 @@ PREFIX ?= /usr/local
|
|||
# MAIN TARGETS
|
||||
#
|
||||
.PHONY: FORCE
|
||||
all: par
|
||||
libpar.a: $(OBJS)
|
||||
all: lr
|
||||
liblr.a: $(OBJS)
|
||||
$(AR) rc $@ $^
|
||||
version.h:
|
||||
./update_ver.sh
|
||||
par: version.h main.o libpar.a
|
||||
lr: version.h main.o liblr.a
|
||||
$(CC) $(filter-out %.h, $^) -o $@ $(LDFLAGS)
|
||||
tests_i386: par tests/i386/bin $(addprefix tests/i386/bin/, $(TESTS_i386)) $(addprefix tests/i386/bin/, $(TESTS_i386)) FORCE
|
||||
tests_x86_64: par tests/x86_64/bin $(addprefix tests/x86_64/bin/, $(TESTS_x86_64)) FORCE
|
||||
tests: par tests_i386 tests_x86_64 FORCE
|
||||
tests_i386: lr tests/i386/bin $(addprefix tests/i386/bin/, $(TESTS_i386)) $(addprefix tests/i386/bin/, $(TESTS_i386)) FORCE
|
||||
tests_x86_64: lr tests/x86_64/bin $(addprefix tests/x86_64/bin/, $(TESTS_x86_64)) FORCE
|
||||
tests: lr tests_i386 tests_x86_64 FORCE
|
||||
@./tests/dotests.sh tests
|
||||
tests_core: $(LIB) tests/core/bin $(addprefix tests/core/bin/, $(TESTS_CORE)) FORCE
|
||||
|
||||
|
@ -39,18 +39,18 @@ tests/i386/bin tests/x86_64/bin tests/core/bin:
|
|||
@mkdir $@
|
||||
tests/core/bin/%: tests/core/%.c $(LIB)
|
||||
$(CC) $< -o $@ $(CFLAGS) $(LDFLAGS) $(LIB) -I.
|
||||
tests/x86_64/bin/%.s: tests/x86_64/%.par par
|
||||
$(VALGRIND) $(PAR) -m x86_64 -o $@ $<
|
||||
tests/x86_64/bin/%.s: tests/all/%.par par
|
||||
$(VALGRIND) $(PAR) -m x86_64 -o $@ $<
|
||||
tests/i386/bin/%.s: tests/all/%.par par
|
||||
$(VALGRIND) $(PAR) -m i386 -o $@ $<
|
||||
tests/i386/bin/%.s: tests/i386/%.par par
|
||||
$(VALGRIND) $(PAR) -m i386 -o $@ $<
|
||||
tests/x86_64/bin/%.s: tests/x86_64/%.lr lr
|
||||
$(VALGRIND) $(LR) -m x86_64 -o $@ $<
|
||||
tests/x86_64/bin/%.s: tests/all/%.lr lr
|
||||
$(VALGRIND) $(LR) -m x86_64 -o $@ $<
|
||||
tests/i386/bin/%.s: tests/all/%.lr lr
|
||||
$(VALGRIND) $(LR) -m i386 -o $@ $<
|
||||
tests/i386/bin/%.s: tests/i386/%.lr lr
|
||||
$(VALGRIND) $(LR) -m i386 -o $@ $<
|
||||
tests/i386/bin/%: tests/i386/bin/%.s
|
||||
$(CC) -m32 $^ -o $@ $(LDFLAGS)
|
||||
%.s: %.par par
|
||||
$(PAR) $<
|
||||
%.s: %.lr lr
|
||||
$(LR) $<
|
||||
%.o: %.s
|
||||
$(AS) $(ASFLAGS) $< -o $@
|
||||
%: %.o
|
||||
|
@ -63,24 +63,24 @@ tests/i386/bin/%: tests/i386/bin/%.s
|
|||
@mkdir -p $@
|
||||
help:
|
||||
@printf "Targets\n"
|
||||
@printf " all Build par (default)\n"
|
||||
@printf " all Build lr (default)\n"
|
||||
@printf " clean Remove build files\n"
|
||||
@printf " tests Build and run tests\n"
|
||||
@printf " tests_core Build lib tests\n"
|
||||
@printf " install_vimfiles Install syntax files in ~/.vim/\n"
|
||||
@printf " install_shell_completion Install bash completion files in /usr/\n"
|
||||
install_vimfiles: FORCE | $(DESTDIR)$(HOME)/.vim/ftdetect $(DESTDIR)$(HOME)/.vim/syntax
|
||||
install -m 644 ./vimfiles/syntax/par.vim $(DESTDIR)$(HOME)/.vim/syntax/
|
||||
install -m 644 ./vimfiles/ftdetect/par.vim $(DESTDIR)$(HOME)/.vim/ftdetect/
|
||||
completion/par: completion/par_template
|
||||
cd completion && PAR=../par ./make_completion.sh
|
||||
install_shell_completion: par completion/par FORCE | /usr/share/bash-completion/completions
|
||||
@sed -i "s/ARCHES=.*/ARCHES='$(shell ./par --list-arches|column)'/" completion/par
|
||||
install -m 644 completion/par /usr/share/bash-completion/completions/
|
||||
install -m 644 ./vimfiles/syntax/lr.vim $(DESTDIR)$(HOME)/.vim/syntax/
|
||||
install -m 644 ./vimfiles/ftdetect/lr.vim $(DESTDIR)$(HOME)/.vim/ftdetect/
|
||||
completion/lr: completion/lr_template
|
||||
cd completion && LR=../lr ./make_completion.sh
|
||||
install_shell_completion: lr completion/lr FORCE | /usr/share/bash-completion/completions
|
||||
@sed -i "s/ARCHES=.*/ARCHES='$(shell ./lr --list-arches|column)'/" completion/lr
|
||||
install -m 644 completion/lr /usr/share/bash-completion/completions/
|
||||
install_docs: FORCE | $(DESTDIR)$(PREFIX)/man/man1
|
||||
install par.1 $(DESTDIR)$(PREFIX)/man/man1/
|
||||
install lr.1 $(DESTDIR)$(PREFIX)/man/man1/
|
||||
install_all: install install_vimfiles install_shell_completion FORCE
|
||||
install: par install_docs $(DESTDIR)$(PREFIX)/bin FORCE
|
||||
install -m 755 par $(DESTDIR)$(PREFIX)/bin/
|
||||
install: lr install_docs $(DESTDIR)$(PREFIX)/bin FORCE
|
||||
install -m 755 lr $(DESTDIR)$(PREFIX)/bin/
|
||||
clean:
|
||||
$(RM) a.out *.o $(OBJS) par libpar.a $(addprefix tests/x86_64/bin/, *.s *.o $(TESTS_x86_64)) tests/core/bin/* tests/x86_64/bin/* listing version.h completion/par
|
||||
$(RM) a.out *.o $(OBJS) lr liblr.a $(addprefix tests/x86_64/bin/, *.s *.o $(TESTS_x86_64)) tests/core/bin/* tests/x86_64/bin/* listing version.h completion/lr
|
||||
|
|
2
TODO
2
TODO
|
@ -1,4 +1,4 @@
|
|||
par
|
||||
lr
|
||||
|
||||
Turn something in a human readable computer language like
|
||||
print('hello');
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
_par()
|
||||
_lr()
|
||||
{
|
||||
local ARCHES=''
|
||||
local cur prev opts
|
||||
|
@ -19,4 +19,4 @@ _par()
|
|||
fi
|
||||
}
|
||||
|
||||
complete -o default -F _par par
|
||||
complete -o default -F _lr lr
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
[ $PAR = '' ] && PAR=../par
|
||||
[ $PAR = '' ] && PAR=../lr
|
||||
|
||||
sed "s/ARCHES=.*/ARCHES='$($PAR --list-arches|column)'/" par_template > par
|
||||
sed "s/ARCHES=.*/ARCHES='$($PAR --list-arches|column)'/" lr > lr
|
||||
|
|
12
par.1 → lr.1
12
par.1 → lr.1
|
@ -1,12 +1,12 @@
|
|||
.IX Title "par 1"
|
||||
.TH par 1 "2023-10-16" "par"
|
||||
.IX Title "lr 1"
|
||||
.TH lr 1 "2023-10-16" "lr"
|
||||
.if n .ad l
|
||||
.nh
|
||||
.SH "NAME"
|
||||
par \- Lexer, parser, and code generator
|
||||
lr \- Lexer, parser, and code generator
|
||||
.SH "SYNOPSIS"
|
||||
.IX Header "SYNOPSIS"
|
||||
usage: par [-bhprt] [-o OUTFILE] [-m ARCH] [--help] [--list-arches] [FILES]
|
||||
usage: lr [-bhprt] [-o OUTFILE] [-m ARCH] [--help] [--list-arches] [FILES]
|
||||
|
||||
.SH "DESCRIPTION"
|
||||
.IX Header "DESCRIPTION"
|
||||
|
@ -57,10 +57,10 @@ Input source files
|
|||
|
||||
.SH "ENVIRONMENT"
|
||||
.IX Header "ENVIRONMENT"
|
||||
See par --help for options.
|
||||
See lr --help for options.
|
||||
.SH "AUTHOR"
|
||||
.IX Header "AUTHOR"
|
||||
\fB<https://git.ylink.one/corey/par\fR>>
|
||||
\fB<https://git.ylink.one/corey/lr\fR>>
|
||||
.SH "COPYRIGHT"
|
||||
.IX Header "COPYRIGHT"
|
||||
.PP
|
4
main.c
4
main.c
|
@ -6,8 +6,8 @@
|
|||
#include"state.h"
|
||||
#include"version.h"
|
||||
|
||||
#define HELPMSG "par v"VERSION"\n"\
|
||||
"usage: par [-behprt] [-o OUTFILE] [-m ARCH] [--help] [--list-arches] [FILES]"
|
||||
#define HELPMSG "lr v"VERSION"\n"\
|
||||
"usage: lr [-behprt] [-o OUTFILE] [-m ARCH] [--help] [--list-arches] [FILES]"
|
||||
#define ARCHESMSG "i386\nir\nrun\nx86_64"
|
||||
|
||||
int main(int argc,char**argv)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/bin/sh
|
||||
#########
|
||||
#
|
||||
# test.par "modeline" syntax:
|
||||
# The first line of a test.par file
|
||||
# test.lr "modeline" syntax:
|
||||
# The first line of a test.lr file
|
||||
# can be one of the following:
|
||||
#
|
||||
# 1. Begins with "#:<RETURNVALUE>" (normal test)
|
||||
|
@ -35,7 +35,7 @@
|
|||
# tests/<ARCH>/.
|
||||
#########
|
||||
|
||||
PAR=../par
|
||||
LR=../lr
|
||||
|
||||
test_program()
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ test_program()
|
|||
if [ -e $PROG ]; then
|
||||
expected=0
|
||||
|
||||
# Check modeline of .par file for expected return
|
||||
# Check modeline of .lr file for expected return
|
||||
if [ -e $PROG_SRC ]; then
|
||||
local modeline="$(sed -n 1p $PROG_SRC)"
|
||||
if [ "$(echo $modeline|cut -c -2)" = '#:' ]; then
|
||||
|
@ -75,7 +75,7 @@ test_program()
|
|||
elif [ $ARCH = 'i386' ]; then
|
||||
"./$PROG" 2>&1 >/dev/null
|
||||
else
|
||||
$PAR -m $ARCH -o /dev/null "./$PROG" 2>&1 >/dev/null
|
||||
$LR -m $ARCH -o /dev/null "./$PROG" 2>&1 >/dev/null
|
||||
fi
|
||||
local result="$?"
|
||||
if [ "$result" = $expected ]; then
|
||||
|
@ -104,12 +104,12 @@ main()
|
|||
local ARCHES='x86_64 i386'
|
||||
|
||||
for arch in $ARCHES; do
|
||||
for sourcefile in $(find all/ $arch/ -name '*.par'); do
|
||||
test_program "$arch/bin/$(basename -s .par $sourcefile)" "$sourcefile" "$arch"
|
||||
for sourcefile in $(find all/ $arch/ -name '*.lr'); do
|
||||
test_program "$arch/bin/$(basename -s .lr $sourcefile)" "$sourcefile" "$arch"
|
||||
done
|
||||
done
|
||||
|
||||
for x in $(find run/ -name '*.par'); do
|
||||
for x in $(find run/ -name '*.lr'); do
|
||||
test_program "$x" "$x" "run"
|
||||
done
|
||||
}
|
||||
|
|
1
vimfiles/ftdetect/lr.vim
Normal file
1
vimfiles/ftdetect/lr.vim
Normal file
|
@ -0,0 +1 @@
|
|||
au BufRead,BufNewFile *.lr set filetype=lr
|
|
@ -1 +0,0 @@
|
|||
au BufRead,BufNewFile *.par set filetype=par
|
24
vimfiles/syntax/lr.vim
Normal file
24
vimfiles/syntax/lr.vim
Normal file
|
@ -0,0 +1,24 @@
|
|||
" Vim syntax file
|
||||
" Language: Lr
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
syn match LrIdent /[a-zA-Z_]\+[a-zA-Z0-9_]*/
|
||||
syn match LrComment /#.*$/ contains=LrTodo
|
||||
syn keyword LrKeyword for while if ret let fn true false asm ext
|
||||
syn match LrInt /\d\+/
|
||||
syn match LrFloat /\d\+\.\d\+/
|
||||
syn match LrEscapes /\\./
|
||||
syn keyword LrTodo contained TODO
|
||||
syn region LrString start=/\v"/ skip=/\v\\./ end=/\v"/ contains=LrEscapes
|
||||
|
||||
hi LrIdent ctermfg=blue guifg=#ff7700
|
||||
hi def link LrComment Comment
|
||||
hi def link LrKeyword Keyword
|
||||
hi def link LrInt Number
|
||||
hi def link LrFloat Float
|
||||
hi def link LrString String
|
||||
hi def link LrEscapes SpecialChar
|
||||
hi def link LrTodo Todo
|
|
@ -1,24 +0,0 @@
|
|||
" Vim syntax file
|
||||
" Language: Par
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
syn match ParIdent /[a-zA-Z_]\+[a-zA-Z0-9_]*/
|
||||
syn match ParComment /#.*$/ contains=ParTodo
|
||||
syn keyword ParKeyword for while if ret let fn true false asm ext
|
||||
syn match ParInt /\d\+/
|
||||
syn match ParFloat /\d\+\.\d\+/
|
||||
syn match ParEscapes /\\./
|
||||
syn keyword ParTodo contained TODO
|
||||
syn region ParString start=/\v"/ skip=/\v\\./ end=/\v"/ contains=ParEscapes
|
||||
|
||||
hi ParIdent ctermfg=blue guifg=#ff7700
|
||||
hi def link ParComment Comment
|
||||
hi def link ParKeyword Keyword
|
||||
hi def link ParInt Number
|
||||
hi def link ParFloat Float
|
||||
hi def link ParString String
|
||||
hi def link ParEscapes SpecialChar
|
||||
hi def link ParTodo Todo
|
Loading…
Reference in New Issue
Block a user