Skip to content

Commit

Permalink
User-specific StringModel #290
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuszgromada committed Dec 27, 2022
1 parent c8fc539 commit 40b06b9
Show file tree
Hide file tree
Showing 34 changed files with 11,258 additions and 3,982 deletions.
3 changes: 2 additions & 1 deletion CURRENT/c-sharp/1-Current-Dev.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@
<Compile Include="src\org\mariuszgromada\math\mxparser\syntaxchecker\TokenMgrError.cs" />
<Compile Include="src\org\mariuszgromada\math\mxparser\SerializationUtils.cs" />
<Compile Include="src\org\mariuszgromada\math\mxparser\StringInvariant.cs" />
<Compile Include="src\org\mariuszgromada\math\mxparser\StringResources.cs" />
<Compile Include="src\org\mariuszgromada\math\mxparser\StringModel.cs" />
<Compile Include="src\org\mariuszgromada\math\mxparser\StringUtils.cs" />
<Compile Include="src\org\mariuszgromada\math\mxparser\Tutorial.cs" />
<Compile Include="src\org\mariuszgromada\math\mxparser\StringResources.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
Expand Down
10 changes: 5 additions & 5 deletions CURRENT/c-sharp/src/org/mariuszgromada/math/mxparser/Argument.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* @(#)Argument.cs 5.2.0 2022-12-09
* @(#)Argument.cs 5.2.0 2022-12-27
*
* MathParser.org-mXparser DUAL LICENSE AGREEMENT as of date 2022-05-22
* The most up-to-date license is available at the below link:
Expand Down Expand Up @@ -267,8 +267,8 @@ public class Argument : PrimitiveElement {
* Argument type id for the definition of key words
* known by the parser.
*/
public const int TYPE_ID = 101;
public static readonly String TYPE_DESC = StringResources.USER_DEFINED_ARGUMENT;
public const int TYPE_ID = 101;
public static String TYPE_DESC = ParserSymbol.NA;
/**
* Argument with body based on the value or expression string.
*
Expand Down Expand Up @@ -331,10 +331,10 @@ public class Argument : PrimitiveElement {
*=================================================
*/
private static String buildErrorMessageInvalidArgumentName(String argumentName) {
return StringResources.buildErrorMessagePatternDoesNotMatchWithExamples(argumentName, StringResources.INVALID_ARGUMENT_NAME, StringInvariant.ARGUMENT_NAME_EXAMPLES);
return StringModel.buildErrorMessagePatternDoesNotMatchWithExamples(argumentName, StringModel.STRING_RESOURCES.INVALID_ARGUMENT_NAME, StringInvariant.ARGUMENT_NAME_EXAMPLES);
}
private static String buildErrorMessageInvalidArgumentDefinition(String argumentDefinitionString) {
return StringResources.buildErrorMessagePatternDoesNotMatchWithExamples(argumentDefinitionString, StringResources.INVALID_ARGUMENT_DEFINITION, StringInvariant.ARGUMENT_DEFINITION_EXAMPLES);
return StringModel.buildErrorMessagePatternDoesNotMatchWithExamples(argumentDefinitionString, StringModel.STRING_RESOURCES.INVALID_ARGUMENT_DEFINITION, StringInvariant.ARGUMENT_DEFINITION_EXAMPLES);
}
/**
* Default constructor - creates argument based on the argument definition string.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* @(#)CalcStepsRegister.cs 5.2.0 2022-12-09
* @(#)CalcStepsRegister.cs 5.2.0 2022-12-27
*
* MathParser.org-mXparser DUAL LICENSE AGREEMENT as of date 2022-05-22
* The most up-to-date license is available at the below link:
Expand Down Expand Up @@ -247,36 +247,36 @@ public class CalcStepsRegister {
*/
public void consolePrint() {
if (calcStepRecords.Count == 0) {
mXparser.consolePrintln(StringResources.CALC_STEPS_REGISTER_IS_EMPTY);
mXparser.consolePrintln(StringModel.STRING_RESOURCES.CALC_STEPS_REGISTER_IS_EMPTY);
return;
}
mXparser.consolePrint(StringResources.CALC_STEPS_REGISTER_FOR + StringInvariant.SPACE);
mXparser.consolePrint(StringModel.STRING_RESOURCES.CALC_STEPS_REGISTER_FOR + StringInvariant.SPACE);
bool toPrintEq = false;
if (argumentNameStart.Length > 0) {
mXparser.consolePrint(StringResources.ARGUMENT + StringInvariant.SPACE + argumentNameStart);
mXparser.consolePrint(StringModel.STRING_RESOURCES.ARGUMENT + StringInvariant.SPACE + argumentNameStart);
toPrintEq = true;
}
if (functionNameStart.Length > 0) {
mXparser.consolePrint(StringResources.FUNCTION + StringInvariant.SPACE + functionNameStart);
mXparser.consolePrint(StringModel.STRING_RESOURCES.FUNCTION + StringInvariant.SPACE + functionNameStart);
toPrintEq = true;
}
if (toPrintEq)
mXparser.consolePrint(StringInvariant.SPACE_EQUAL_SPACE);
else
mXparser.consolePrint(StringResources.EXPRESSION + StringInvariant.SPACE);
mXparser.consolePrint(StringModel.STRING_RESOURCES.EXPRESSION + StringInvariant.SPACE);
mXparser.consolePrintln(expressionStringStart + ", result = " + result);
mXparser.consolePrintln(expressionStringStart + StringInvariant.COMMA_SPACE + StringResources.RESULT + StringInvariant.SPACE_EQUAL_SPACE + result);
mXparser.consolePrintln(expressionStringStart + StringInvariant.COMMA_SPACE + StringModel.STRING_RESOURCES.RESULT + StringInvariant.SPACE_EQUAL_SPACE + result);
foreach (CalcStepRecord stepRecord in calcStepRecords)
mXparser.consolePrintln(
StringResources.GROUP_SHORT + StringInvariant.SPACE_EQUAL_SPACE + stepRecord.numberGroup
+ StringInvariant.COMMA_SPACE + StringResources.NUMBER_SHORT + StringInvariant.SPACE_EQUAL_SPACE + stepRecord.numberGroupWithin
+ StringInvariant.COMMA_SPACE + StringResources.FIRST + StringInvariant.SPACE_EQUAL_SPACE + stepRecord.firstInGroup
+ StringInvariant.COMMA_SPACE + StringResources.LAST + StringInvariant.SPACE_EQUAL_SPACE + stepRecord.lastInGroup
+ StringInvariant.COMMA_SPACE + StringResources.TYPE + StringInvariant.SPACE_EQUAL_SPACE + stepRecord.type
+ StringInvariant.COMMA_SPACE + StringResources.DESCRIPTION_SHORT + StringInvariant.SPACE_EQUAL_SPACE + stepRecord.description
+ StringInvariant.COMMA_SPACE + StringResources.STEP + StringInvariant.SPACE_EQUAL_SPACE + stepRecord.content
StringModel.STRING_RESOURCES.GROUP_SHORT + StringInvariant.SPACE_EQUAL_SPACE + stepRecord.numberGroup
+ StringInvariant.COMMA_SPACE + StringModel.STRING_RESOURCES.NUMBER_SHORT + StringInvariant.SPACE_EQUAL_SPACE + stepRecord.numberGroupWithin
+ StringInvariant.COMMA_SPACE + StringModel.STRING_RESOURCES.FIRST + StringInvariant.SPACE_EQUAL_SPACE + stepRecord.firstInGroup
+ StringInvariant.COMMA_SPACE + StringModel.STRING_RESOURCES.LAST + StringInvariant.SPACE_EQUAL_SPACE + stepRecord.lastInGroup
+ StringInvariant.COMMA_SPACE + StringModel.STRING_RESOURCES.TYPE + StringInvariant.SPACE_EQUAL_SPACE + stepRecord.type
+ StringInvariant.COMMA_SPACE + StringModel.STRING_RESOURCES.DESCRIPTION_SHORT + StringInvariant.SPACE_EQUAL_SPACE + stepRecord.description
+ StringInvariant.COMMA_SPACE + StringModel.STRING_RESOURCES.STEP + StringInvariant.SPACE_EQUAL_SPACE + stepRecord.content
);
mXparser.consolePrintln(StringResources.COMPUTING_TIME + StringInvariant.SPACE_EQUAL_SPACE + computingTime + " s.");
mXparser.consolePrintln(StringModel.STRING_RESOURCES.COMPUTING_TIME + StringInvariant.SPACE_EQUAL_SPACE + computingTime + " s.");
}
internal bool isStartSet = false;
internal int stepNumberGroup = 0;
Expand Down
15 changes: 7 additions & 8 deletions CURRENT/c-sharp/src/org/mariuszgromada/math/mxparser/Constant.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* @(#)Constant.cs 5.2.0 2022-12-09
* @(#)Constant.cs 5.2.0 2022-12-27
*
* MathParser.org-mXparser DUAL LICENSE AGREEMENT as of date 2022-05-22
* The most up-to-date license is available at the below link:
Expand Down Expand Up @@ -224,14 +224,13 @@ public class Constant : PrimitiveElement {
/**
* Type identifier for constants
*/
public const int TYPE_ID = 104;
public static readonly String TYPE_DESC = StringResources.USER_DEFINED_CONSTANT;
public const int TYPE_ID = 104;
public static String TYPE_DESC = ParserSymbol.NA;
/**
* Status of the Expression syntax
*/
public const bool NO_SYNTAX_ERRORS = Expression.NO_SYNTAX_ERRORS;
public const bool SYNTAX_ERROR_OR_STATUS_UNKNOWN = Expression.SYNTAX_ERROR_OR_STATUS_UNKNOWN;
private static readonly String NO_SYNTAX_ERROR_MSG = StringResources.NO_ERRORS_DETECTED;
/**
* Name of the constant
*/
Expand Down Expand Up @@ -261,10 +260,10 @@ public class Constant : PrimitiveElement {
*/
private String errorMessage;
private static String buildErrorMessageInvalidConstantName(String constantName) {
return StringResources.buildErrorMessagePatternDoesNotMatchWithExamples(constantName, StringResources.INVALID_CONSTANT_NAME, StringInvariant.CONSTANT_NAME_EXAMPLES);
return StringModel.buildErrorMessagePatternDoesNotMatchWithExamples(constantName, StringModel.STRING_RESOURCES.INVALID_CONSTANT_NAME, StringInvariant.CONSTANT_NAME_EXAMPLES);
}
private static String buildErrorMessageInvalidConstantDefinitionString(String constantDefinitionString) {
return StringResources.buildErrorMessagePatternDoesNotMatchWithExamples(constantDefinitionString, StringResources.INVALID_CONSTANT_DEFINITION, StringInvariant.CONSTANT_DEFINITION_EXAMPLES);
return StringModel.buildErrorMessagePatternDoesNotMatchWithExamples(constantDefinitionString, StringModel.STRING_RESOURCES.INVALID_CONSTANT_DEFINITION, StringInvariant.CONSTANT_DEFINITION_EXAMPLES);
}
/**
* Constructor - creates constant with a given name and given value
Expand All @@ -280,7 +279,7 @@ public Constant(String constantName, double constantValue) : base(Constant.TYPE_
this.constantValue = constantValue;
description = StringInvariant.EMPTY;
syntaxStatus = NO_SYNTAX_ERRORS;
errorMessage = NO_SYNTAX_ERROR_MSG;
errorMessage = StringModel.STRING_RESOURCES.NO_ERRORS_DETECTED;
} else {
syntaxStatus = SYNTAX_ERROR_OR_STATUS_UNKNOWN;
errorMessage = buildErrorMessageInvalidConstantName(constantName);
Expand All @@ -301,7 +300,7 @@ public Constant(String constantName, double constantValue, String description) :
this.constantValue = constantValue;
this.description = description;
syntaxStatus = NO_SYNTAX_ERRORS;
errorMessage = NO_SYNTAX_ERROR_MSG;
errorMessage = StringModel.STRING_RESOURCES.NO_ERRORS_DETECTED;
}
else {
syntaxStatus = SYNTAX_ERROR_OR_STATUS_UNKNOWN;
Expand Down
Loading

0 comments on commit 40b06b9

Please sign in to comment.