gonna replace makefile in next commit so im just chucking it here
This commit is contained in:
parent
8e06149d1a
commit
d2ab7aab00
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
.vscode/
|
||||
build/
|
||||
*.mod
|
||||
*.smod
|
||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,6 +1,3 @@
|
||||
[submodule "libs/f90getopt"]
|
||||
path = libs/f90getopt
|
||||
url = https://github.com/PKM74/f90getopt
|
||||
[submodule "libs/stdlib"]
|
||||
path = libs/stdlib
|
||||
url = https://github.com/fortran-lang/stdlib
|
||||
|
||||
13
Makefile
13
Makefile
@ -1,9 +1,13 @@
|
||||
FC=gfortran
|
||||
FFLAGS=-std=f2008 -fdec-structure
|
||||
FFLAGS=-std=f2023 -fdec-structure
|
||||
BUILD_DIR=build
|
||||
SRC_DIR=src
|
||||
LIBS_DIR=libs
|
||||
INCLUDE_DIR=/usr/include/
|
||||
INCLUDE_DIR=/usr/include/fortran_stdlib/GNU-15.1.1/
|
||||
SYSLIB_DIR=/usr/lib/
|
||||
|
||||
STDLIB_CFLAGS := `pkg-config --cflags fortran_stdlib`
|
||||
STDLIB_LIBS := `pkg-config --libs fortran_stdlib`
|
||||
|
||||
SOURCES_FORTRAN = $(wildcard $(SRC_DIR)/*.f90)
|
||||
|
||||
@ -23,9 +27,7 @@ LIBS_FORTRAN = $(wildcard $(LIBS_DIR)/*.f90) \
|
||||
all: always main
|
||||
|
||||
main:
|
||||
$(FC) $(FFLAGS) $(LIBS_FORTRAN) $(SOURCES_FORTRAN) -o $(BUILD_DIR)/fcc -I$(INCLUDE_DIR)
|
||||
|
||||
|
||||
$(FC) $(FFLAGS) $(STDLIB_CFLAGS) $(STDLIB_LIBS) $(LIBS_FORTRAN) $(SOURCES_FORTRAN) -o $(BUILD_DIR)/fcc
|
||||
|
||||
always:
|
||||
mkdir -p $(BUILD_DIR)
|
||||
@ -33,3 +35,4 @@ always:
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR)
|
||||
rm $(wildcard *.mod)
|
||||
rm $(wildcard *.smod)
|
||||
@ -4,3 +4,8 @@ I'm doing this for fun... might as well... oh and im writing it in fortran too..
|
||||
This is PURE fucking masochism...
|
||||
|
||||
im not explaining that sentence...
|
||||
|
||||
## Build Requirements
|
||||
- FYPP
|
||||
- fortran_stdlibs
|
||||
- gfortran
|
||||
@ -1 +0,0 @@
|
||||
Subproject commit 30ccd9d46496126a24f240ccfa6f9f9c762219a5
|
||||
10
src/main.f90
10
src/main.f90
@ -15,8 +15,7 @@ program main
|
||||
! local variables
|
||||
character(len=1) :: short ! getopt-character
|
||||
character(:), allocatable :: output
|
||||
character(:), allocatable :: input
|
||||
character(:), allocatable :: tokenized_input
|
||||
character(:), allocatable :: input, tokenized_input, input_deliminators
|
||||
|
||||
integer :: pos
|
||||
|
||||
@ -50,14 +49,13 @@ program main
|
||||
exit
|
||||
end if
|
||||
print*, "Input Data: ", input
|
||||
call prttkn0(trim(input), '#')
|
||||
! call engtkn0(input, '', pos, tokenized_input)
|
||||
! print*, "Tokenized Input Data: ", tokenized_input
|
||||
call tokenize(input, len(input), input_deliminators, tokenized_input)
|
||||
print*, "Tokenized Input Data: ", tokenized_input
|
||||
|
||||
case("h")
|
||||
print*, "USAGE: -i --input-file | -o --output-file | -v --version | -h --help"
|
||||
case("v")
|
||||
print*, "Fortran C Compiler Version RD-00002"
|
||||
print*, "Fortran C Compiler Version RD-00003"
|
||||
end select
|
||||
end do
|
||||
! END processing options
|
||||
|
||||
@ -2,113 +2,30 @@
|
||||
! yay..
|
||||
|
||||
module tokenizer
|
||||
use stdlib_strings
|
||||
implicit none
|
||||
contains
|
||||
|
||||
subroutine prttkn0(str,del)
|
||||
implicit none
|
||||
character (len=9000), intent(in) :: str
|
||||
character (len=20), intent(in) :: del
|
||||
character (len=100) :: tkn
|
||||
integer :: pos
|
||||
print *,"Delimiters:"
|
||||
print *,del
|
||||
print *,"str:"
|
||||
print *,str
|
||||
pos=1
|
||||
!
|
||||
print *,"token:"
|
||||
call engtkn0(str,del,pos,tkn)
|
||||
do while (tkn/="")
|
||||
! do while (pos<LEN_TRIM(str))!works
|
||||
print *,tkn
|
||||
call engtkn0(str,del,pos,tkn)
|
||||
end do
|
||||
print *,tkn
|
||||
print *,""
|
||||
return
|
||||
!
|
||||
end subroutine
|
||||
!'-------------------------------------------------
|
||||
!subroutine
|
||||
!end subroutine
|
||||
!'-------------------------------------------------
|
||||
subroutine engtkn0(str,del,pos,tkn)
|
||||
implicit none
|
||||
!
|
||||
character(len=20) :: eof,whtsp,nul
|
||||
COMMON eof,whtsp,nul
|
||||
!
|
||||
character (len=9000), intent(in) :: str
|
||||
character (len=20), intent(in) :: del
|
||||
integer, intent(inout) :: pos
|
||||
character (len=100),intent(out) :: tkn
|
||||
integer :: oldpos,newpos
|
||||
!
|
||||
tkn=""
|
||||
if (str=="") return
|
||||
oldpos=pos
|
||||
if (del==whtsp) then!if (del=="._~#!',:;-") then
|
||||
call Delim0(str,del,oldpos,newpos)
|
||||
pos=newpos
|
||||
if (LEN_TRIM(str)<=pos) return
|
||||
oldpos=pos
|
||||
call Tkn0(str,del,oldpos,newpos)
|
||||
tkn=str(oldpos:newpos-1)
|
||||
pos=newpos
|
||||
return
|
||||
else if (del==eof) then!else if (del=="_") then
|
||||
oldpos=pos
|
||||
call Tkndelim0(str,del,oldpos,newpos)
|
||||
tkn=str(oldpos:newpos)
|
||||
pos=newpos+1
|
||||
if (index(tkn,trim(del))==0) then
|
||||
tkn=trim(tkn)//trim(del)
|
||||
end if
|
||||
return
|
||||
else if (del==nul) then!else if (del=="") then
|
||||
tkn=str(pos:pos)
|
||||
pos=pos+1
|
||||
subroutine tokenize(input_string, string_length, delim, tokens)
|
||||
integer, intent(in) :: string_length
|
||||
character(:), allocatable, intent(in) :: delim
|
||||
character(:), allocatable, intent(out) :: tokens
|
||||
character(string_length), intent(in) :: input_string
|
||||
|
||||
character(1000) :: buffer
|
||||
character(1) :: c
|
||||
integer :: i
|
||||
|
||||
if (string_length == 0) then
|
||||
print*, 'Tokenizer: String Length 0'
|
||||
return
|
||||
end if
|
||||
!**************************************************
|
||||
Contains
|
||||
!'-------------------------------------------------
|
||||
subroutine Delim0(str,del,oldpos,newpos)
|
||||
implicit none
|
||||
character (len=9000), intent(in) :: str
|
||||
character (len=20), intent(in) :: del
|
||||
integer, intent(in) :: oldpos
|
||||
integer, intent(out) :: newpos
|
||||
if (LEN_TRIM(str)<pos) return
|
||||
do newpos=oldpos,LEN_TRIM(str)
|
||||
if (index(del,str(newpos:newpos))<1) exit
|
||||
|
||||
do while (i < string_length)
|
||||
call slice_string(input_string, i, i+1)
|
||||
i = i + 1
|
||||
end do
|
||||
end subroutine
|
||||
!'-------------------------------------------------
|
||||
subroutine Tkn0(str,del,oldpos,newpos)
|
||||
implicit none
|
||||
character (len=1000), intent(in) :: str
|
||||
character (len=20), intent(in) :: del
|
||||
integer, intent(in) :: oldpos
|
||||
integer, intent(out) :: newpos
|
||||
do newpos=oldpos,LEN_TRIM(str)
|
||||
if (index(del,str(newpos:newpos))>0) exit
|
||||
end do
|
||||
end subroutine
|
||||
!'-------------------------------------------------
|
||||
subroutine Tkndelim0(str,del,oldpos,newpos)
|
||||
implicit none
|
||||
character (len=9000), intent(in) :: str
|
||||
character (len=20), intent(in) :: del
|
||||
integer, intent(in) :: oldpos
|
||||
integer, intent(out) :: newpos
|
||||
do newpos=oldpos,LEN_TRIM(str)
|
||||
if (index(str(oldpos:newpos),trim(del))>0) exit
|
||||
end do
|
||||
end subroutine
|
||||
!'-------------------------------------------------
|
||||
!**************************************************
|
||||
end subroutine
|
||||
|
||||
end subroutine tokenize
|
||||
|
||||
end module tokenizer
|
||||
Loading…
x
Reference in New Issue
Block a user