|
|
|
@ -544,28 +544,29 @@ private final function bool ParseTextValue(
|
|
|
|
|
Command.Parameter expectedParameter) |
|
|
|
|
{ |
|
|
|
|
local bool failedParsing; |
|
|
|
|
local string textValue; |
|
|
|
|
local parser.ParserState initialState; |
|
|
|
|
// TODO: use parsing methods into `Text` |
|
|
|
|
local MutableText textValue; |
|
|
|
|
local Parser.ParserState initialState; |
|
|
|
|
|
|
|
|
|
// (needs some work for reading formatting `string`s from `Text` objects) |
|
|
|
|
initialState = commandParser.Skip().GetCurrentState(); |
|
|
|
|
// Try manually parsing as a string literal first, since then we will |
|
|
|
|
// allow empty `textValue` as a result |
|
|
|
|
commandParser.MStringLiteralS(textValue); |
|
|
|
|
commandParser.MStringLiteral(textValue); |
|
|
|
|
failedParsing = !commandParser.Ok(); |
|
|
|
|
// Otherwise - empty values are not allowed |
|
|
|
|
if (failedParsing) |
|
|
|
|
{ |
|
|
|
|
commandParser.RestoreState(initialState).MStringS(textValue); |
|
|
|
|
failedParsing = (!commandParser.Ok() || textValue == ""); |
|
|
|
|
_.memory.Free(textValue); |
|
|
|
|
commandParser.RestoreState(initialState).MString(textValue); |
|
|
|
|
failedParsing = (!commandParser.Ok() || textValue.IsEmpty()); |
|
|
|
|
} |
|
|
|
|
if (failedParsing) |
|
|
|
|
{ |
|
|
|
|
_.memory.Free(textValue); |
|
|
|
|
commandParser.Fail(); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
RecordParameter(parsedParameters, expectedParameter, |
|
|
|
|
_.text.FromString(textValue)); |
|
|
|
|
RecordParameter(parsedParameters, expectedParameter, textValue.IntoText()); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|