Skip to content

Commit 34c72c3

Browse files
committed
Improve parameter recognition and fix bugs
1 parent 7880a37 commit 34c72c3

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

src/ui/panel/ParameterView.re

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ let make = (~goblint_path, ~inputValue, ~setInputValue,~disableRun, ~setDisableR
141141

142142
setInputValue(inputVal => {
143143
let new_inputVal = String.cat(parameter, inputVal);
144-
let _ = check_input(new_inputVal);
145144
new_inputVal
146145
});
147146
}
@@ -158,9 +157,9 @@ let make = (~goblint_path, ~inputValue, ~setInputValue,~disableRun, ~setDisableR
158157
|> ((p,b)) => (p, p |> ParameterUtils.tuples_from_parameters, b);
159158

160159
// To prevent invalid default input to be executed, with i.e. blacklisted options, we check the input value first
161-
let isInvalid = react_on_input(tuple_parameter_list, is_malformed, inputValue);
160+
/*let isInvalid = react_on_input(tuple_parameter_list, is_malformed, inputValue);*/
162161

163-
if (!isInvalid) {
162+
if (inputState == Ok && !is_malformed) {
164163
let time = Time.get_local_time();
165164
let element = (parameter_list, time, Executing, "");
166165

@@ -199,7 +198,16 @@ let make = (~goblint_path, ~inputValue, ~setInputValue,~disableRun, ~setDisableR
199198
let config_call_function = () => {
200199
config_opts
201200
|> List.map(((k,v)) => {
202-
`List([`String(k), Yojson.Safe.from_string(v)])
201+
let v' = if (!String.equal("true", v) &&
202+
!String.equal("false", v) &&
203+
(!String.starts_with(~prefix="[", v) && !String.ends_with(~suffix="]", v) &&
204+
!Str.string_match((Str.regexp({|^[0-9]+$|})), v, 0))) {
205+
"\"" ++ v ++ "\"" // check whether value is a string => wrap it in ""
206+
} else {
207+
v
208+
};
209+
210+
`List([`String(k), Yojson.Safe.from_string(v')])
203211
|> Yojson.Safe.to_string
204212
|> Body.of_string;
205213
})
@@ -348,7 +356,7 @@ let make = (~goblint_path, ~inputValue, ~setInputValue,~disableRun, ~setDisableR
348356
| Malformed
349357
| Blacklisted
350358
| Empty => <Input class_=["form-control", "is-invalid"] value=inputValue on_change on_submit key="tooltip_path" />
351-
| Ok => <Input value=inputValue on_change on_submit key="tooltip_path" /*id=input_id*/ />;
359+
| Ok => <Input value=inputValue on_change on_submit key="tooltip_path" />;
352360
}}
353361
{switch inputState {
354362
| Ok => React.null;
@@ -371,11 +379,11 @@ let make = (~goblint_path, ~inputValue, ~setInputValue,~disableRun, ~setDisableR
371379
</div>
372380
<div className="col-2" onClick=on_sort style={ReactDOM.Style.make(~cursor="pointer", ())}>
373381
{"Time " |> React.string}
374-
{switch sortDesc {
375-
| true => <IconArrowUp />
376-
| _ => <IconArrowDown />
377-
};
378-
}
382+
{if (sortDesc) {
383+
<IconArrowUp />
384+
} else {
385+
<IconArrowDown />
386+
}}
379387
</div>
380388
<div className="col">
381389
{"Parameters" |> React.string}

src/utils/ParameterUtils.re

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ open State
33
let concat_parameter_list = String.concat(" ");
44
let concat_grouped_parameters = (parameters) => parameters |> List.map(concat_parameter_list) |> concat_parameter_list;
55

6-
let parameters_regex = Str.regexp({|\(--\(enable\|disable\) [-a-zA-Z0-9\._]+\)\|\(--set [-a-zA-Z0-9\._]+\(\[\(\+\|\-\)\]\)? [a-zA-Z0-9\._\/-]+\|\("\|'\)[a-zA-Z0-9\._, \!\?\$\*\/-]*\("\|'\)\|\[\(\(\(\("\|'\)[a-zA-Z0-9\._, \!\?\$\*\/-]*\("\|'\)\|[a-zA-Z0-9\._\/-]+\)\(\([ ]*,[ ]*\)\(\("\|'\)[a-zA-Z0-9\._, \!\?\$\*\/-]*\("\|'\)\|[a-zA-Z0-9\._\/-]+\)\)*\)\|\(\("\|'\)[a-zA-Z0-9\._, \!\?\$\*\/-]*\("\|'\)\)\|[a-zA-Z0-9\._\/-]*\)\]\)\|\(--[-a-zA-Z0-9\._]+\(\[\(\+\|\-\)\]\)? \([a-zA-Z0-9\._\/-]+\|\("\|'\)[a-zA-Z0-9\._, \!\?\$\*\/-]*\("\|'\)\|\[\(\(\(\("\|'\)[a-zA-Z0-9\._, \!\?\$\*\/-]*\("\|'\)\|[a-zA-Z0-9\._\/-]+\)\(\([ ]*,[ ]*\)\(\("\|'\)[a-zA-Z0-9\._, \!\?\$\*\/-]*\("\|'\)\|[a-zA-Z0-9\._\/-]+\)\)*\)\|\(\("\|'\)[a-zA-Z0-9\._, \!\?\$\*\/-]*\("\|'\)\)\|[a-zA-Z0-9\._\/-]*\)\]\)\)|});
6+
let parameters_regex = Str.regexp({|\(--\(enable\|disable\) [-a-zA-Z0-9\._]+\)\|\(--set [-a-zA-Z0-9\._]+\(\[\(\+\|\-\)\]\)? [-a-zA-Z0-9\._\/]+\|\("\|'\)[-a-zA-Z0-9\._, \!\?\$\*\/]*\("\|'\)\|\[\(\(\(\("\|'\)[-a-zA-Z0-9\._, \!\?\$\*\/]*\("\|'\)\|[-a-zA-Z0-9\._\/]+\)\(\([ ]*,[ ]*\)\(\("\|'\)[-a-zA-Z0-9\._, \!\?\$\*\/]*\("\|'\)\|[-a-zA-Z0-9\._\/]+\)\)*\)\|\(\("\|'\)[-a-zA-Z0-9\._, \!\?\$\*\/]*\("\|'\)\)\|[-a-zA-Z0-9\._\/]*\)\]\)\|\(--[-a-zA-Z0-9\._]+\(\[\(\+\|\-\)\]\)? \([-a-zA-Z0-9\._\/]+\|\("\|'\)[-a-zA-Z0-9\._, \!\?\$\*\/]*\("\|'\)\|\[\(\(\(\("\|'\)[-a-zA-Z0-9\._, \!\?\$\*\/]*\("\|'\)\|[-a-zA-Z0-9\._\/]+\)\(\([ ]*,[ ]*\)\(\("\|'\)[-a-zA-Z0-9\._, \!\?\$\*\/]*\("\|'\)\|[-a-zA-Z0-9\._\/]+\)\)*\)\|\(\("\|'\)[-a-zA-Z0-9\._, \!\?\$\*\/]*\("\|'\)\)\|[-a-zA-Z0-9\._\/]*\)\]\)\)|});
77
let enable_disable_regex = Str.regexp({|--\(enable\|disable\) \([-a-zA-Z0-9\._]+\)|});
8-
let set_regex = Str.regexp({|--set \([-a-zA-Z0-9\._]+\(\[\(\+\|\-\)\]\)?\) \([a-zA-Z0-9\._\/-]+\|\("\|'\)[a-zA-Z0-9\._, \!\?\$\*\/-]*\("\|'\)\|\[\(\(\(\("\|'\)[a-zA-Z0-9\._, \!\?\$\*\/-]*\("\|'\)\|[a-zA-Z0-9\._\/-]+\)\(\([ ]*,[ ]*\)\(\("\|'\)[a-zA-Z0-9\._, \!\?\$\*\/-]*\("\|'\)\|[a-zA-Z0-9\._\/-]+\)\)*\)\|\(\("\|'\)[a-zA-Z0-9\._, \!\?\$\*\/-]*\("\|'\)\)\|[a-zA-Z0-9\._\/-]*\)\]\)|});
9-
let other_regex = Str.regexp({|--\([-a-zA-Z0-9\._]+\(\[\(\+\|\-\)\]\)?\) \([a-zA-Z0-9\._\/-]+\|\("\|'\)[a-zA-Z0-9\._, \!\?\$\*\/-]*\("\|'\)\|\[\(\(\(\("\|'\)[a-zA-Z0-9\._, \!\?\$\*\/-]*\("\|'\)\|[a-zA-Z0-9\._\/-]+\)\(\([ ]*,[ ]*\)\(\("\|'\)[a-zA-Z0-9\._, \!\?\$\*\/-]*\("\|'\)\|[a-zA-Z0-9\._\/-]+\)\)*\)\|\(\("\|'\)[a-zA-Z0-9\._, \!\?\$\*\/-]*\("\|'\)\)\|[a-zA-Z0-9\._\/-]*\)\]\)|});
8+
let set_regex = Str.regexp({|--set \([-a-zA-Z0-9\._]+\(\[\(\+\|\-\)\]\)?\) \([-a-zA-Z0-9\._\/]+\|\("\|'\)[-a-zA-Z0-9\._, \!\?\$\*\/]*\("\|'\)\|\[\(\(\(\("\|'\)[-a-zA-Z0-9\._, \!\?\$\*\/]*\("\|'\)\|[-a-zA-Z0-9\._\/]+\)\(\([ ]*,[ ]*\)\(\("\|'\)[-a-zA-Z0-9\._, \!\?\$\*\/]*\("\|'\)\|[-a-zA-Z0-9\._\/]+\)\)*\)\|\(\("\|'\)[-a-zA-Z0-9\._, \!\?\$\*\/]*\("\|'\)\)\|[-a-zA-Z0-9\._\/]*\)\]\)|});
9+
let other_regex = Str.regexp({|--\([-a-zA-Z0-9\._]+\(\[\(\+\|\-\)\]\)?\) \([-a-zA-Z0-9\._\/]+\|\("\|'\)[-a-zA-Z0-9\._, \!\?\$\*\/]*\("\|'\)\|\[\(\(\(\("\|'\)[-a-zA-Z0-9\._, \!\?\$\*\/]*\("\|'\)\|[-a-zA-Z0-9\._\/]+\)\(\([ ]*,[ ]*\)\(\("\|'\)[-a-zA-Z0-9\._, \!\?\$\*\/]*\("\|'\)\|[-a-zA-Z0-9\._\/]+\)\)*\)\|\(\("\|'\)[-a-zA-Z0-9\._, \!\?\$\*\/]*\("\|'\)\)\|[-a-zA-Z0-9\._\/]*\)\]\)|});
1010
let string_with_upticks_regex = Str.regexp({|'\(.*\)'|});
1111

1212
// Reads Goblint's path and the parameters which were taken into consideration by Goblint for the first analysis

0 commit comments

Comments
 (0)