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/
|
.vscode/
|
||||||
build/
|
build/
|
||||||
*.mod
|
*.mod
|
||||||
|
*.smod
|
||||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,6 +1,3 @@
|
|||||||
[submodule "libs/f90getopt"]
|
[submodule "libs/f90getopt"]
|
||||||
path = libs/f90getopt
|
path = libs/f90getopt
|
||||||
url = https://github.com/PKM74/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
|
FC=gfortran
|
||||||
FFLAGS=-std=f2008 -fdec-structure
|
FFLAGS=-std=f2023 -fdec-structure
|
||||||
BUILD_DIR=build
|
BUILD_DIR=build
|
||||||
SRC_DIR=src
|
SRC_DIR=src
|
||||||
LIBS_DIR=libs
|
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)
|
SOURCES_FORTRAN = $(wildcard $(SRC_DIR)/*.f90)
|
||||||
|
|
||||||
@ -23,9 +27,7 @@ LIBS_FORTRAN = $(wildcard $(LIBS_DIR)/*.f90) \
|
|||||||
all: always main
|
all: always main
|
||||||
|
|
||||||
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:
|
always:
|
||||||
mkdir -p $(BUILD_DIR)
|
mkdir -p $(BUILD_DIR)
|
||||||
@ -33,3 +35,4 @@ always:
|
|||||||
clean:
|
clean:
|
||||||
rm -rf $(BUILD_DIR)
|
rm -rf $(BUILD_DIR)
|
||||||
rm $(wildcard *.mod)
|
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...
|
This is PURE fucking masochism...
|
||||||
|
|
||||||
im not explaining that sentence...
|
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
|
! local variables
|
||||||
character(len=1) :: short ! getopt-character
|
character(len=1) :: short ! getopt-character
|
||||||
character(:), allocatable :: output
|
character(:), allocatable :: output
|
||||||
character(:), allocatable :: input
|
character(:), allocatable :: input, tokenized_input, input_deliminators
|
||||||
character(:), allocatable :: tokenized_input
|
|
||||||
|
|
||||||
integer :: pos
|
integer :: pos
|
||||||
|
|
||||||
@ -50,14 +49,13 @@ program main
|
|||||||
exit
|
exit
|
||||||
end if
|
end if
|
||||||
print*, "Input Data: ", input
|
print*, "Input Data: ", input
|
||||||
call prttkn0(trim(input), '#')
|
call tokenize(input, len(input), input_deliminators, tokenized_input)
|
||||||
! call engtkn0(input, '', pos, tokenized_input)
|
print*, "Tokenized Input Data: ", tokenized_input
|
||||||
! print*, "Tokenized Input Data: ", tokenized_input
|
|
||||||
|
|
||||||
case("h")
|
case("h")
|
||||||
print*, "USAGE: -i --input-file | -o --output-file | -v --version | -h --help"
|
print*, "USAGE: -i --input-file | -o --output-file | -v --version | -h --help"
|
||||||
case("v")
|
case("v")
|
||||||
print*, "Fortran C Compiler Version RD-00002"
|
print*, "Fortran C Compiler Version RD-00003"
|
||||||
end select
|
end select
|
||||||
end do
|
end do
|
||||||
! END processing options
|
! END processing options
|
||||||
|
|||||||
@ -2,113 +2,30 @@
|
|||||||
! yay..
|
! yay..
|
||||||
|
|
||||||
module tokenizer
|
module tokenizer
|
||||||
|
use stdlib_strings
|
||||||
implicit none
|
implicit none
|
||||||
contains
|
contains
|
||||||
|
|
||||||
subroutine prttkn0(str,del)
|
subroutine tokenize(input_string, string_length, delim, tokens)
|
||||||
implicit none
|
integer, intent(in) :: string_length
|
||||||
character (len=9000), intent(in) :: str
|
character(:), allocatable, intent(in) :: delim
|
||||||
character (len=20), intent(in) :: del
|
character(:), allocatable, intent(out) :: tokens
|
||||||
character (len=100) :: tkn
|
character(string_length), intent(in) :: input_string
|
||||||
integer :: pos
|
|
||||||
print *,"Delimiters:"
|
character(1000) :: buffer
|
||||||
print *,del
|
character(1) :: c
|
||||||
print *,"str:"
|
integer :: i
|
||||||
print *,str
|
|
||||||
pos=1
|
if (string_length == 0) then
|
||||||
!
|
print*, 'Tokenizer: String Length 0'
|
||||||
print *,"token:"
|
return
|
||||||
call engtkn0(str,del,pos,tkn)
|
end if
|
||||||
do while (tkn/="")
|
|
||||||
! do while (pos<LEN_TRIM(str))!works
|
do while (i < string_length)
|
||||||
print *,tkn
|
call slice_string(input_string, i, i+1)
|
||||||
call engtkn0(str,del,pos,tkn)
|
i = i + 1
|
||||||
end do
|
end do
|
||||||
print *,tkn
|
|
||||||
print *,""
|
end subroutine tokenize
|
||||||
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
|
|
||||||
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
|
|
||||||
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 module tokenizer
|
end module tokenizer
|
||||||
Loading…
x
Reference in New Issue
Block a user