Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
orangecat
ollama
Commits
e6bae8d9
Commit
e6bae8d9
authored
Jul 20, 2023
by
Jeffrey Morgan
Browse files
parser: keep seeking until eof
parent
d9f54300
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
11 deletions
+5
-11
parser/parser.go
parser/parser.go
+5
-11
No files found.
parser/parser.go
View file @
e6bae8d9
...
@@ -71,22 +71,16 @@ func scanModelfile(data []byte, atEOF bool) (advance int, token []byte, err erro
...
@@ -71,22 +71,16 @@ func scanModelfile(data []byte, atEOF bool) (advance int, token []byte, err erro
if
start
:=
bytes
.
Index
(
data
,
[]
byte
(
`"""`
));
start
>=
0
&&
start
<
newline
{
if
start
:=
bytes
.
Index
(
data
,
[]
byte
(
`"""`
));
start
>=
0
&&
start
<
newline
{
end
:=
bytes
.
Index
(
data
[
start
+
3
:
],
[]
byte
(
`"""`
))
end
:=
bytes
.
Index
(
data
[
start
+
3
:
],
[]
byte
(
`"""`
))
if
end
<
0
{
if
end
<
0
{
return
0
,
nil
,
errors
.
New
(
`unterminated multiline string: """`
)
if
atEOF
{
return
0
,
nil
,
errors
.
New
(
`unterminated multiline string: """`
)
}
else
{
return
0
,
nil
,
nil
}
}
}
n
:=
start
+
3
+
end
+
3
n
:=
start
+
3
+
end
+
3
return
n
,
bytes
.
Replace
(
data
[
:
n
],
[]
byte
(
`"""`
),
[]
byte
(
""
),
2
),
nil
return
n
,
bytes
.
Replace
(
data
[
:
n
],
[]
byte
(
`"""`
),
[]
byte
(
""
),
2
),
nil
}
}
if
start
:=
bytes
.
Index
(
data
,
[]
byte
(
`'''`
));
start
>=
0
&&
start
<
newline
{
end
:=
bytes
.
Index
(
data
[
start
+
3
:
],
[]
byte
(
`'''`
))
if
end
<
0
{
return
0
,
nil
,
errors
.
New
(
"unterminated multiline string: '''"
)
}
n
:=
start
+
3
+
end
+
3
return
n
,
bytes
.
Replace
(
data
[
:
n
],
[]
byte
(
"'''"
),
[]
byte
(
""
),
2
),
nil
}
return
bufio
.
ScanLines
(
data
,
atEOF
)
return
bufio
.
ScanLines
(
data
,
atEOF
)
}
}
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