📄 stafcpar.rxl
字号:
if PS_IsLiteral then PS_CurrType = "Value" else if ValueIsOption(PS_CurrData) \= 0 then PS_CurrType = "Option" PS_Word.0 = PS_Word.0 + 1 PS_WordIndex = PS_Word.0 PS_Word.PS_WordIndex.!Type = PS_CurrType PS_Word.PS_WordIndex.!Data = PS_CurrData PS_CurrType = "Value" PS_CurrData = "" PS_InQuotes = 0 PS_IsLiteral = 0 end else do PS_InQuotes = 1 PS_IsLiteral = 1 end PS_InEscape = 0 end /* end if quote character */ else do PS_InEscape = 0 PS_CurrData = PS_CurrData || PS_Char end end /* looping through parse string */ if PS_InLengthField | PS_InDataField then do call VALUE PS_ErrorBuffer, "Invalid length delimited data specifier" RETURN 1 end else if PS_CurrData \== "" then do if PS_IsLiteral then PS_CurrType = "Value" else if ValueIsOption(PS_CurrData) \= 0 then PS_CurrType = "Option" PS_Word.0 = PS_Word.0 + 1 PS_WordIndex = PS_Word.0 PS_Word.PS_WordIndex.!Type = PS_CurrType PS_Word.PS_WordIndex.!Data = PS_CurrData end /* Now walk the word list looking for options, etc. */ PS_ValueRequirement = "NO" PS_CurrOption = "" PS_CurrValue = "" do PS_i = 1 to PS_Word.0 PS_CurrWord = PS_Word.PS_i.!Data if PS_Word.PS_i.!Type = "Option" then do do PS_OptionIndex = 1 to STAFCommandParser.!Option.SCP_CurrentParser.0, UNTIL TRANSLATE(STAFCommandParser.!Option.SCP_CurrentParser.PS_OptionIndex.!Name) =, TRANSLATE(PS_CurrWord) end if PS_ValueRequirement = "YES" then do call VALUE PS_ErrorBuffer, "Option," PS_CurrOption",", "requires a value" RETURN 1 end else if PS_ValueRequirement = "ALLOWED" then do STAFCommandParser.!Instance.SCP_CurrentParser.0 = STAFCommandParser.!Instance.SCP_CurrentParser.0 + 1 PS_InstanceIndex = STAFCommandParser.!Instance.SCP_CurrentParser.0 STAFCommandParser.!Instance.SCP_CurrentParser.PS_InstanceIndex.!Name = PS_CurrOption STAFCommandParser.!Instance.SCP_CurrentParser.PS_InstanceIndex.!Value = PS_CurrValue end /* Check once here for whether this new option instance will */ /* exceed the limit for this option */ if (OptionTimes(STAFCommandParser.!Option.SCP_CurrentParser.PS_OptionIndex.!Name) =, STAFCommandParser.!Option.SCP_CurrentParser.PS_OptionIndex.!Times) &, (STAFCommandParser.!Option.SCP_CurrentParser.PS_OptionIndex.!Times \= 0) then do call VALUE PS_ErrorBuffer, "You may have no more than", STAFCommandParser.!Option.SCP_CurrentParser.PS_OptionIndex.!Times, "instance(s) of option", STAFCommandParser.!Option.SCP_CurrentParser.PS_OptionIndex.!Name RETURN 1 end PS_CurrOption = STAFCommandParser.!Option.SCP_CurrentParser.PS_OptionIndex.!Name PS_CurrValue = "" PS_ValueRequirement =, TRANSLATE(STAFCommandParser.!Option.SCP_CurrentParser.PS_OptionIndex.!ValueRequired) if PS_ValueRequirement = "NO" then do STAFCommandParser.!Instance.SCP_CurrentParser.0 = STAFCommandParser.!Instance.SCP_CurrentParser.0 + 1 PS_InstanceIndex = STAFCommandParser.!Instance.SCP_CurrentParser.0 STAFCommandParser.!Instance.SCP_CurrentParser.PS_InstanceIndex.!Name = PS_CurrOption STAFCommandParser.!Instance.SCP_CurrentParser.PS_InstanceIndex.!Value = PS_CurrValue PS_CurrOption = "" PS_CurrValue = "" end end else if PS_ValueRequirement = "NO" then do STAFCommandParser.!Arg.SCP_CurrentParser.0 = STAFCommandParser.!Arg.SCP_CurrentParser.0 + 1 PS_ArgIndex = STAFCommandParser.!Arg.SCP_CurrentParser.0 STAFCommandParser.!Arg.SCP_CurrentParser.PS_ArgIndex = PS_CurrWord end else do PS_CurrValue = PS_CurrWord STAFCommandParser.!Instance.SCP_CurrentParser.0 = STAFCommandParser.!Instance.SCP_CurrentParser.0 + 1 PS_InstanceIndex = STAFCommandParser.!Instance.SCP_CurrentParser.0 STAFCommandParser.!Instance.SCP_CurrentParser.PS_InstanceIndex.!Name = PS_CurrOption STAFCommandParser.!Instance.SCP_CurrentParser.PS_InstanceIndex.!Value = PS_CurrValue PS_CurrOption = "" PS_CurrValue = "" PS_ValueRequirement = "NO" end end /* end for each word */ /* If the last word was an option, we need to check for its value */ /* requirements here */ if PS_ValueRequirement = "YES" then do call VALUE PS_ErrorBuffer, "Option,", STAFCommandParser.!Option.SCP_CurrentParser.PS_OptionIndex.!Name",", "requires a value" RETURN 1 end else if PS_ValueRequirement = "ALLOWED" then do STAFCommandParser.!Instance.SCP_CurrentParser.0 = STAFCommandParser.!Instance.SCP_CurrentParser.0 + 1 PS_InstanceIndex = STAFCommandParser.!Instance.SCP_CurrentParser.0 STAFCommandParser.!Instance.SCP_CurrentParser.PS_InstanceIndex.!Name = PS_CurrOption STAFCommandParser.!Instance.SCP_CurrentParser.PS_InstanceIndex.!Value = PS_CurrValue end /* Check the restriction on number of arguments */ if STAFCommandParser.!Arg.SCP_CurrentParser.0 >, STAFCommandParser.!MaxArguments.SCP_CurrentParser then do PS_InvalidArgIndex = STAFCommandParser.!MaxArguments.SCP_CurrentParser + 1 call VALUE PS_ErrorBuffer, "You may have no more than", STAFCommandParser.!MaxArguments.SCP_CurrentParser "argument(s).", " You specified" STAFCommandParser.!Arg.SCP_CurrentParser.0, "argument(s). The first excess argument is, ", STAFCommandParser.!Arg.SCP_CurrentParser.PS_InvalidArgIndex"." RETURN 1 end /* Now check all the group requirements */ do PS_i = 1 to STAFCommandParser.!OptionGroup.SCP_CurrentParser.0 PS_GroupCount = 0 PS_GroupWordCount =, WORDS(STAFCommandParser.!OptionGroup.SCP_CurrentParser.PS_i.!Group) do PS_j = 1 to PS_GroupWordCount if OptionTimes(WORD(STAFCommandParser.!OptionGroup.SCP_CurrentParser.PS_i.!Group, PS_j)) \= 0 then PS_GroupCount = PS_GroupCount + 1 end if (PS_GroupCount <, STAFCommandParser.!OptionGroup.SCP_CurrentParser.PS_i.!Minimum) |, (PS_GroupCount >, STAFCommandParser.!OptionGroup.SCP_CurrentParser.PS_i.!Maximum) then do call VALUE PS_ErrorBuffer, "You must have at least", STAFCommandParser.!OptionGroup.SCP_CurrentParser.PS_I.!Minimum",", "but no more than", STAFCommandParser.!OptionGroup.SCP_CurrentParser.PS_I.!Maximum, "of the option(s),", STAFCommandParser.!OptionGroup.SCP_CurrentParser.PS_I.!Group RETURN 1 end end /* do for each group */ /* Now check the need requirements */ do PS_i = 1 to STAFCommandParser.!OptionNeed.SCP_CurrentParser.0 PS_FoundNeeder = 0 PS_FoundNeedee = 0 do PS_j = 1 to WORDS(STAFCommandParser.!OptionNeed.SCP_CurrentParser.PS_I.!Needer), while PS_FoundNeeder = 0 if (OptionTimes(WORD(STAFCommandParser.!OptionNeed.SCP_CurrentParser.PS_i.!Needer, PS_j)) \= 0) then PS_FoundNeeder = 1 end do PS_j = 1 to WORDS(STAFCommandParser.!OptionNeed.SCP_CurrentParser.PS_I.!Needee), while PS_FoundNeedee = 0 if (OptionTimes(WORD(STAFCommandParser.!OptionNeed.SCP_CurrentParser.PS_i.!Needee, PS_j)) \= 0) then PS_FoundNeedee = 1 end if (PS_FoundNeeder & \PS_FoundNeedee) then do call VALUE PS_ErrorBuffer, "When specifying one of the options", STAFCommandParser.!OptionNeed.SCP_CurrentParser.PS_i.!Needer",", "you must also specify one of the options", STAFCommandParser.!OptionNeed.SCP_CurrentParser.PS_i.!Needee RETURN 1 end end /* do for each need */ RETURN 0/* End of ParseString */#From STAFCPar Import OptionTimes ValueIsOption#End#Function ValueIsOption/******************************************************************************//* ValueIsOption - Determines if a given string is an option *//* *//* Accepts: The string to check *//* *//* Returns: 0, if the string is not an option *//* Otherwise, returns the index into the current parser's !Option *//* array which corresponds to this option *//******************************************************************************/ValueIsOption: parse arg VIO_Value do VIO_i = 1 to STAFCommandParser.!Option.SCP_CurrentParser.0 if TRANSLATE(STAFCommandParser.!Option.SCP_CurrentParser.VIO_i.!Name) =, TRANSLATE(VIO_Value) then do RETURN VIO_i end end RETURN 0/* End of ValueIsOption */#End
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -