Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
GenerateFiles
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Antonino D'Anna
GenerateFiles
Commits
07bbfcdb
Commit
07bbfcdb
authored
Apr 27, 2026
by
Antonino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added StringViews and write(::Records). Removed emacs files
parent
d99998d0
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
60 additions
and
66 deletions
+60
-66
.gitignore
.gitignore
+2
-0
Manifest.toml
Manifest.toml
+5
-2
Project.toml
Project.toml
+6
-0
src/#types.jl#
src/#types.jl#
+0
-43
src/.#types.jl
src/.#types.jl
+0
-1
src/GeneratedFiles.jl
src/GeneratedFiles.jl
+1
-0
src/filemanip.jl
src/filemanip.jl
+29
-15
src/types.jl
src/types.jl
+17
-5
No files found.
.gitignore
0 → 100644
View file @
07bbfcdb
#*
.#*
Manifest.toml
View file @
07bbfcdb
...
@@ -2,6 +2,9 @@
...
@@ -2,6 +2,9 @@
julia_version
=
"1.11.6"
julia_version
=
"1.11.6"
manifest_format
=
"2.0"
manifest_format
=
"2.0"
project_hash
=
"
da39a3ee5e6b4b0d3255bfef95601890afd80709
"
project_hash
=
"
bd39c77bc66a0e20a3905bc4afca19c6a1650ebb
"
[deps]
[[deps.StringViews]]
git-tree-sha1
=
"f2dcb92855b31ad92fe8f079d4f75ac57c93e4b8"
uuid
=
"354b36f9-a18e-4713-926e-db85100087ba"
version
=
"1.3.7"
Project.toml
View file @
07bbfcdb
...
@@ -2,3 +2,9 @@ name = "GeneratedFiles"
...
@@ -2,3 +2,9 @@ name = "GeneratedFiles"
uuid
=
"dd08c5e9-7c90-4908-81e2-08ae9a8bbe49"
uuid
=
"dd08c5e9-7c90-4908-81e2-08ae9a8bbe49"
authors
=
[
"Antonino <anda982008@gmail.com>"
]
authors
=
[
"Antonino <anda982008@gmail.com>"
]
version
=
"0.1.0"
version
=
"0.1.0"
[deps]
StringViews
=
"354b36f9-a18e-4713-926e-db85100087ba"
[compat]
StringViews
=
"1.3.7"
src/#types.jl#
deleted
100644 → 0
View file @
d99998d0
mutable struct Tag
tag::String
#=
Order records by position. if pos<0 they are put at the end of the list.
=#
pos::Int64 ##
Tag(s, pos) = new(s,pos)
Tag(s) = Tag(s,-1)
end
mutable struct Record
buffer::IOBuffer
tag::Tag
Record(b::IOBuffer,tag::Tag) = new(b,tag)
Record(b::IOBuffer,tag::AbstractString, pos::Int64 = -1) = new(b,Tag(tag,pos))
Record(b,tag::Tag) = new(IOBuffer(b),tag)
Record(b,tag::AbstractString,pos::Int64=-1) = new(IOBuffer(b),Tag(tag,pos))
end
mutable struct GeneratedFile
filename::String
records::Vector{Record}
GeneratedFile(io::String, r::Vector{Record} = Record[]) = new(io,r)
end
import Base: show
function show(io::IO,gf::GeneratedFile)
nr = length(gf.records)
print(io,"GeneratedFile: $(gf.filename) with $nr records")
end
show(io::IO,r::Record) = show(io,r.tag)
show(io::IO,t::Tag) = print(io,"Tag: ", t.tag," position: ", t.pos)
import Base: print
function Base.print(io::IO,r::Record)
nchar = div(r.buffer.size,sizeof(Char))
nchar >80
print(io,"Record: ",r.tag.tag,"\nText: ",String(take!(r.buffer)))
end
src/.#types.jl
deleted
120000 → 0
View file @
d99998d0
nuccio
@nuccio
-
Lenovo
-
IdeaPad
-
S340
-
15
API
.
41142
:
1776683147
\ No newline at end of file
src/GeneratedFiles.jl
View file @
07bbfcdb
module
GeneratedFiles
module
GeneratedFiles
using
StringViews
include
(
"types.jl"
)
include
(
"types.jl"
)
include
(
"filemanip.jl"
)
include
(
"filemanip.jl"
)
...
...
src/filemanip.jl
View file @
07bbfcdb
...
@@ -30,18 +30,11 @@ function findEndRecord(io::IOStream)
...
@@ -30,18 +30,11 @@ function findEndRecord(io::IOStream)
return
p2
return
p2
end
end
function
readRecord
(
io
)
is
=
position
(
io
)
ie
=
findEndRecord
(
io
)
seek
(
io
,
is
)
buffer
=
IOBuffer
(
read
(
io
,
ie
-
is
))
return
Record
(
buffer
)
end
function
readGF
(
filename
)
function
readGF
(
filename
)
records
=
Vector
{
Record
}()
records
=
Vector
{
Record
}()
open
(
filename
,
"r"
)
do
io
open
(
filename
,
"r"
)
do
io
while
seekRecord
(
io
)
while
seekRecord
(
io
)
push!
(
records
,
read
R
ecord
(
io
))
push!
(
records
,
read
_r
ecord
(
io
))
end
end
end
end
return
GeneratedFile
(
filename
,
records
)
return
GeneratedFile
(
filename
,
records
)
...
@@ -55,7 +48,7 @@ function get_tag_and_pos(s::AbstractString)
...
@@ -55,7 +48,7 @@ function get_tag_and_pos(s::AbstractString)
return
tag
,
pos
return
tag
,
pos
end
end
function
Record
(
b
::
IOBuffer
)
function
read_record
(
b
::
IO
)
tag
,
pos
=
get_tag_and_pos
(
readline
(
b
))
tag
,
pos
=
get_tag_and_pos
(
readline
(
b
))
is
=
position
(
b
)
is
=
position
(
b
)
length
=
0
length
=
0
...
@@ -67,7 +60,7 @@ function Record(b::IOBuffer)
...
@@ -67,7 +60,7 @@ function Record(b::IOBuffer)
me
=
match
(
TAG_REGEX
,
l
)
me
=
match
(
TAG_REGEX
,
l
)
isnothing
(
me
)
&&
error
(
"missing tag at the end of a Record"
)
isnothing
(
me
)
&&
error
(
"missing tag at the end of a Record"
)
if
tag
!=
me
.
match
if
tag
!=
me
.
match
error
(
"Record is malformed:
\n
It start with
$
(
ms.match
)
\n
It ends with
$
(me.match)"
)
error
(
"Record is malformed:
\n
It start with
$(
tag
)
\n
It ends with
$
(me.match)"
)
end
end
break
;
break
;
end
end
...
@@ -75,18 +68,37 @@ function Record(b::IOBuffer)
...
@@ -75,18 +68,37 @@ function Record(b::IOBuffer)
return
Record
(
IOBuffer
(
read
(
b
,
length
)),
tag
,
pos
)
return
Record
(
IOBuffer
(
read
(
b
,
length
)),
tag
,
pos
)
end
end
add_records!
(
GF
::
GeneratedFile
,
r
::
Record
...
)
=
push!
(
GF
.
records
,
r
...
)
import
Base
.
isequal
Base
.
isequal
(
a
::
Tag
,
b
::
Tag
)
=
isequal
(
a
.
tag
,
b
.
tag
)
function
add_records
!
(
GF
::
GeneratedFile
,
r
::
Record
...
)
idx
=
fill
(
true
,
length
(
r
))
for
(
i
,
_r
)
in
enumerate
(
r
)
_idx
=
findfirst
(
x
->
isequal
(
x
.
tag
,
_r
.
tag
),
GF
.
records
)
!
isnothing
(
_idx
)
||
continue
GF
.
records
[
_idx
]
=
_r
idx
[
i
]
=
false
end
push!
(
GF
.
records
,
r
[
idx
]
...
)
end
remove_records!
(
GF
::
GeneratedFile
,
tag
::
String
)
=
filter!
(
r
->
r
.
tag
.
tag
!=
tag
,
GF
.
records
)
remove_records!
(
GF
::
GeneratedFile
,
tag
::
String
)
=
filter!
(
r
->
r
.
tag
.
tag
!=
tag
,
GF
.
records
)
remove_records!
(
GF
::
GeneratedFile
,
tag
::
Tag
)
=
remove_record
(
GF
,
tag
.
tag
)
remove_records!
(
GF
::
GeneratedFile
,
tag
::
Tag
)
=
remove_record
(
GF
,
tag
.
tag
)
import
Base
.
write
function
Base
.
write
(
r
::
Record
,
x
...
)
r
.
buffer
.
writable
||
error
(
"Cannot modify record
$
(r.tag.tag)"
)
Base
.
write
(
r
.
buffer
,
x
...
)
end
function
GF_write
(
io
,
r
::
Record
)
function
GF_write
(
io
,
r
::
Record
)
println
(
io
,
START_RECORD
,
" "
,
r
.
tag
.
tag
,
" "
,
r
.
tag
.
pos
)
println
(
io
,
START_RECORD
,
" "
,
r
.
tag
.
tag
,
" "
,
r
.
tag
.
pos
)
print
(
io
,
String
(
take!
(
r
.
buffer
)))
sw
=
StringView
(
r
.
buffer
.
data
[
1
:
r
.
buffer
.
size
])
seekend
(
r
.
buffer
)
print
(
io
,
sw
)
seek
(
r
.
buffer
,
position
(
r
.
buffer
)
-
1
)
sw
[
end
]
==
'\n'
||
println
(
io
)
startswith
(
r
.
buffer
,
"
\n
"
)
||
print
(
io
,
"
\n
"
)
println
(
io
,
END_RECORD
,
" "
,
r
.
tag
.
tag
)
println
(
io
,
END_RECORD
,
" "
,
r
.
tag
.
tag
)
nothing
nothing
end
end
...
@@ -97,6 +109,8 @@ function isless_Tag(a::Tag,b::Tag)
...
@@ -97,6 +109,8 @@ function isless_Tag(a::Tag,b::Tag)
end
end
isless_Record
(
a
::
Record
,
b
::
Record
)
=
isless_Tag
(
a
.
tag
,
b
.
tag
)
isless_Record
(
a
::
Record
,
b
::
Record
)
=
isless_Tag
(
a
.
tag
,
b
.
tag
)
function
resolve_negative_pos
!
(
R
::
Vector
{
Record
})
function
resolve_negative_pos
!
(
R
::
Vector
{
Record
})
any
(
r
.
tag
.
pos
<=
0
for
r
in
R
)
||
return
any
(
r
.
tag
.
pos
<=
0
for
r
in
R
)
||
return
maxP
=
max
(
1
,
maximum
(
R
[
i
]
.
tag
.
pos
for
i
in
eachindex
(
R
))
+
1
)
maxP
=
max
(
1
,
maximum
(
R
[
i
]
.
tag
.
pos
for
i
in
eachindex
(
R
))
+
1
)
...
...
src/types.jl
View file @
07bbfcdb
...
@@ -4,17 +4,27 @@ mutable struct Tag
...
@@ -4,17 +4,27 @@ mutable struct Tag
Order records by position. if pos<0 they are put at the end of the list.
Order records by position. if pos<0 they are put at the end of the list.
=#
=#
pos
::
Int64
##
pos
::
Int64
##
Tag
(
s
,
pos
)
=
new
(
s
,
pos
)
Tag
(
s
=
""
,
pos
=-
1
)
=
new
(
s
,
pos
)
Tag
(
s
)
=
Tag
(
s
,
-
1
)
end
end
mutable struct
Record
mutable struct
Record
buffer
::
IOBuffer
buffer
::
IOBuffer
tag
::
Tag
tag
::
Tag
Record
(
b
::
IOBuffer
,
tag
::
Tag
)
=
new
(
b
,
tag
)
Record
(
b
::
IOBuffer
,
tag
::
Tag
)
=
new
(
b
,
tag
)
Record
(
b
::
IOBuffer
,
tag
::
AbstractString
,
pos
::
Int64
=
-
1
)
=
new
(
b
,
Tag
(
tag
,
pos
))
Record
(
b
::
IOBuffer
,
tag
::
AbstractString
=
""
,
pos
::
Int64
=
-
1
)
=
new
(
b
,
Tag
(
tag
,
pos
))
Record
(
b
,
tag
::
Tag
)
=
new
(
IOBuffer
(
b
),
tag
)
function
Record
(
b
,
tag
::
Tag
)
Record
(
b
,
tag
::
AbstractString
,
pos
::
Int64
=-
1
)
=
new
(
IOBuffer
(
b
),
Tag
(
tag
,
pos
))
buf
=
IOBuffer
()
write
(
buf
,
b
)
new
(
buf
,
tag
)
end
function
Record
(
b
,
tag
::
AbstractString
=
""
,
pos
::
Int64
=-
1
)
buf
=
IOBuffer
()
write
(
buf
,
b
)
t
=
Tag
(
tag
,
pos
)
new
(
buf
,
t
)
end
Record
(
tag
::
Tag
)
=
new
(
IOBuffer
(),
tag
)
Record
(
tag
::
AbstractString
=
""
,
pos
::
Int64
=-
1
)
=
new
(
IOBuffer
(),
Tag
(
tag
,
pos
))
end
end
mutable struct
GeneratedFile
mutable struct
GeneratedFile
...
@@ -37,5 +47,7 @@ show(io::IO,t::Tag) = print(io,"Tag: ", t.tag," position: ", t.pos)
...
@@ -37,5 +47,7 @@ show(io::IO,t::Tag) = print(io,"Tag: ", t.tag," position: ", t.pos)
import
Base
:
print
import
Base
:
print
function
Base
.
print
(
io
::
IO
,
r
::
Record
)
function
Base
.
print
(
io
::
IO
,
r
::
Record
)
nchar
=
div
(
r
.
buffer
.
size
,
sizeof
(
Char
))
nchar
>
80
print
(
io
,
"Record: "
,
r
.
tag
.
tag
,
"
\n
Text: "
,
String
(
take!
(
r
.
buffer
)))
print
(
io
,
"Record: "
,
r
.
tag
.
tag
,
"
\n
Text: "
,
String
(
take!
(
r
.
buffer
)))
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment