Skip to content

Commit 7e8b273

Browse files
committed
Update
1 parent 3ba8eb2 commit 7e8b273

File tree

3 files changed

+8
-26
lines changed
  • docs/src/submodules/FileFormats
  • src/FileFormats/LP
  • test/FileFormats/LP

3 files changed

+8
-26
lines changed

docs/src/submodules/FileFormats/LP.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ In addition to the grammar, there are the following rules:
3838

3939
```
4040
<lp-file> :==
41-
<keyword-objective>
42-
[<section-objective>]
43-
<keyword-constraints>
41+
<keyword-objective>\n
42+
[<section-objective>\n]
43+
<keyword-constraints>\n
4444
(<constraint>)*
45-
[<keyword-bounds> (<bound-expression>)+]
46-
[<keyword-general> (<identifier>)+]
47-
[<keyword-binary> (<identifier>)+]
48-
[<keyword-sos> (<constraint-sos>)+]
45+
[<keyword-bounds>\n (<bound-expression>)+]
46+
[<keyword-general>\n (<identifier>)+]
47+
[<keyword-binary>\n (<identifier>)+]
48+
[<keyword-sos>\n (<constraint-sos>)+]
4949
[<keyword-end>]
5050
5151
<keyword-objective> :==

src/FileFormats/LP/read.jl

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ struct _ReadCache{T}
2929
end
3030
end
3131

32-
function _read_newline_or_eof(state)
33-
if (p = peek(state, _Token)) !== nothing
34-
_ = read(state, _Token, _TOKEN_NEWLINE)
35-
end
36-
return
37-
end
38-
3932
"""
4033
Base.read!(io::IO, model::FileFormats.LP.Model)
4134
@@ -60,7 +53,6 @@ function Base.read!(io::IO, model::Model{T}) where {T}
6053
if token.kind == _TOKEN_KEYWORD
6154
_ = read(state, _Token)
6255
keyword = Symbol(token.value)
63-
_read_newline_or_eof(state)
6456
elseif token.kind == _TOKEN_NEWLINE
6557
_ = read(state, _Token, _TOKEN_NEWLINE)
6658
elseif keyword == :MINIMIZE
@@ -884,7 +876,6 @@ function _parse_objective(state::_LexerState, cache::_ReadCache)
884876
end
885877
f = _parse_expression(state, cache)
886878
MOI.set(cache.model, MOI.ObjectiveFunction{typeof(f)}(), f)
887-
_read_newline_or_eof(state)
888879
return
889880
end
890881

@@ -931,7 +922,6 @@ function _parse_bound_expression(state, cache)
931922
x = _parse_identifier(state, cache)
932923
set = _parse_set_suffix(state, cache)
933924
_add_bound(cache, x, set)
934-
_read_newline_or_eof(state)
935925
return
936926
end
937927
# `a op x` or `a op x op b`
@@ -946,7 +936,6 @@ function _parse_bound_expression(state, cache)
946936
rhs_set = _parse_set_suffix(state, cache)
947937
_add_bound(cache, x, rhs_set)
948938
end
949-
_read_newline_or_eof(state)
950939
return
951940
end
952941

@@ -1051,6 +1040,5 @@ function _parse_constraint(state::_LexerState, cache::_ReadCache)
10511040
if name !== nothing
10521041
MOI.set(cache.model, MOI.ConstraintName(), c, name)
10531042
end
1054-
_read_newline_or_eof(state)
10551043
return
10561044
end

test/FileFormats/LP/LP.jl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -976,8 +976,7 @@ function test_read_newline_breaks()
976976
+ z ==
977977
0
978978
Bounds
979-
x >= 0
980-
-1 <= y
979+
x >= 0 -1 <= y
981980
+1 <= z <= +2
982981
End
983982
"""
@@ -1540,11 +1539,6 @@ function test_new_line_edge_case_fails()
15401539
"maximize\nobj: x subject to",
15411540
# No new line between subject to and constraint
15421541
"maximize\nobj: x\nsubject to c: x >= 0",
1543-
# No new line between multiple constraints
1544-
"maximize\nobj: x\nsubject to\nc: x >= 0 x <= 1",
1545-
# New lines in bounds section
1546-
"maximize\nobj: x\nsubject to\nbounds x >= 0\bx <= 1",
1547-
"maximize\nobj: x\nsubject to\nbounds\nx >= 0 x <= 1",
15481542
]
15491543
io = IOBuffer(input)
15501544
seekstart(io)

0 commit comments

Comments
 (0)