|
|
@ -400,23 +400,29 @@ private final function bool ParseSingleValue( |
|
|
|
AssociativeArray parsedParameters, |
|
|
|
AssociativeArray parsedParameters, |
|
|
|
Command.Parameter expectedParameter) |
|
|
|
Command.Parameter expectedParameter) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// First we try `CPT_Remainder` parameter, since it is a special case that |
|
|
|
|
|
|
|
// consumes all further input |
|
|
|
|
|
|
|
if (expectedParameter.type == CPT_Remainder) { |
|
|
|
|
|
|
|
return ParseRemainderValue(parsedParameters, expectedParameter); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Before parsing any other value we need to check if user has |
|
|
|
// Before parsing any other value we need to check if user has |
|
|
|
// specified any options instead. |
|
|
|
// specified any options instead. |
|
|
|
// However this might lead to errors if we are already parsing |
|
|
|
// However this might lead to errors if we are already parsing |
|
|
|
// necessary parameters of another option: |
|
|
|
// necessary parameters of another option: |
|
|
|
// we must handle such situation and report an error. |
|
|
|
// we must handle such situation and report an error. |
|
|
|
if ( currentTargetIsOption && currentTarget != CPT_ExtraParameter |
|
|
|
if (currentTargetIsOption) |
|
|
|
&& TryParsingOptions()) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
DeclareError(CET_NoRequiredParamForOption, targetOption.longName); |
|
|
|
// There is no problem is option's parameter is remainder |
|
|
|
return false; |
|
|
|
if (expectedParameter.type == CPT_Remainder) { |
|
|
|
|
|
|
|
return ParseRemainderValue(parsedParameters, expectedParameter); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (currentTarget != CPT_ExtraParameter && TryParsingOptions()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
DeclareError(CET_NoRequiredParamForOption, targetOption.longName); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
while (TryParsingOptions()); |
|
|
|
while (TryParsingOptions()); |
|
|
|
|
|
|
|
// First we try `CPT_Remainder` parameter, since it is a special case that |
|
|
|
|
|
|
|
// consumes all further input |
|
|
|
|
|
|
|
if (expectedParameter.type == CPT_Remainder) { |
|
|
|
|
|
|
|
return ParseRemainderValue(parsedParameters, expectedParameter); |
|
|
|
|
|
|
|
} |
|
|
|
// Propagate errors after parsing options |
|
|
|
// Propagate errors after parsing options |
|
|
|
if (nextResult.parsingError != CET_None) { |
|
|
|
if (nextResult.parsingError != CET_None) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -567,15 +573,13 @@ private final function bool ParseRemainderValue( |
|
|
|
AssociativeArray parsedParameters, |
|
|
|
AssociativeArray parsedParameters, |
|
|
|
Command.Parameter expectedParameter) |
|
|
|
Command.Parameter expectedParameter) |
|
|
|
{ |
|
|
|
{ |
|
|
|
local string textValue; |
|
|
|
local MutableText value; |
|
|
|
// TODO: use parsing methods into `Text` |
|
|
|
|
|
|
|
// (needs some work for reading formatting `string`s from `Text` objects) |
|
|
|
commandParser.Skip().MUntil(value); |
|
|
|
commandParser.Skip().MUntilS(textValue); |
|
|
|
|
|
|
|
if (!commandParser.Ok()) { |
|
|
|
if (!commandParser.Ok()) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
RecordParameter(parsedParameters, expectedParameter, |
|
|
|
RecordParameter(parsedParameters, expectedParameter, value.IntoText()); |
|
|
|
_.text.FromString(textValue)); |
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|