mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-24 22:07:33 +00:00
refactor: prepare preprocessor error improvement
This commit is contained in:
parent
a48dd52d9f
commit
3cc68235dd
@ -1,4 +1,4 @@
|
|||||||
# Warning, "version" should be the same in gradle.properties and Version.java
|
# Warning, "version" should be the same in gradle.properties and Version.java
|
||||||
# Any idea anyone how to magically synchronize those :-) ?
|
# Any idea anyone how to magically synchronize those :-) ?
|
||||||
version = 1.2024.4beta4
|
version = 1.2024.4beta5
|
||||||
org.gradle.workers.max = 3
|
org.gradle.workers.max = 3
|
@ -56,7 +56,7 @@ import net.sourceforge.plantuml.security.SFile;
|
|||||||
import net.sourceforge.plantuml.security.SecurityProfile;
|
import net.sourceforge.plantuml.security.SecurityProfile;
|
||||||
import net.sourceforge.plantuml.security.SecurityUtils;
|
import net.sourceforge.plantuml.security.SecurityUtils;
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
import net.sourceforge.plantuml.tim.TVariableScope;
|
import net.sourceforge.plantuml.tim.TVariableScope;
|
||||||
import net.sourceforge.plantuml.utils.Log;
|
import net.sourceforge.plantuml.utils.Log;
|
||||||
@ -82,7 +82,7 @@ public class Defines implements Truth {
|
|||||||
return new Defines();
|
return new Defines();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyTo(TMemory memory, StringLocated location) throws EaterExceptionLocated {
|
public void copyTo(TMemory memory, StringLocated location) throws EaterException {
|
||||||
for (Entry<String, Define> ent : values.entrySet()) {
|
for (Entry<String, Define> ent : values.entrySet()) {
|
||||||
final String name = ent.getKey();
|
final String name = ent.getKey();
|
||||||
final Define def = ent.getValue();
|
final Define def = ent.getValue();
|
||||||
|
@ -42,7 +42,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.text.TLineType;
|
import net.sourceforge.plantuml.text.TLineType;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.EaterStartsub;
|
import net.sourceforge.plantuml.tim.EaterStartsub;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -79,7 +79,7 @@ public class Sub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Sub fromFile(ReadLine reader, String blocname, TContext context, TMemory memory)
|
public static Sub fromFile(ReadLine reader, String blocname, TContext context, TMemory memory)
|
||||||
throws IOException, EaterExceptionLocated {
|
throws IOException, EaterException {
|
||||||
Sub result = null;
|
Sub result = null;
|
||||||
StringLocated s = null;
|
StringLocated s = null;
|
||||||
boolean skip = false;
|
boolean skip = false;
|
||||||
|
@ -53,7 +53,7 @@ import net.sourceforge.plantuml.preproc.StartDiagramExtractReader;
|
|||||||
import net.sourceforge.plantuml.preproc.Stdlib;
|
import net.sourceforge.plantuml.preproc.Stdlib;
|
||||||
import net.sourceforge.plantuml.security.SURL;
|
import net.sourceforge.plantuml.security.SURL;
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.utils.Log;
|
import net.sourceforge.plantuml.utils.Log;
|
||||||
|
|
||||||
public class PreprocessorUtils {
|
public class PreprocessorUtils {
|
||||||
@ -133,7 +133,7 @@ public class PreprocessorUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ReadLine getReaderIncludeUrl(final SURL url, StringLocated s, String suf, Charset charset)
|
public static ReadLine getReaderIncludeUrl(final SURL url, StringLocated s, String suf, Charset charset)
|
||||||
throws EaterExceptionLocated {
|
throws EaterException {
|
||||||
try {
|
try {
|
||||||
if (StartDiagramExtractReader.containsStartDiagram(url, s, charset))
|
if (StartDiagramExtractReader.containsStartDiagram(url, s, charset))
|
||||||
return StartDiagramExtractReader.build(url, s, suf, charset);
|
return StartDiagramExtractReader.build(url, s, suf, charset);
|
||||||
@ -141,16 +141,16 @@ public class PreprocessorUtils {
|
|||||||
return getReaderInclude(url, s, charset);
|
return getReaderInclude(url, s, charset);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Logme.error(e);
|
Logme.error(e);
|
||||||
throw EaterExceptionLocated.located("Cannot open URL " + e.getMessage(), s);
|
throw new EaterException("Cannot open URL " + e.getMessage(), s);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ReadLine getReaderInclude(SURL url, StringLocated s, Charset charset)
|
public static ReadLine getReaderInclude(SURL url, StringLocated s, Charset charset)
|
||||||
throws EaterExceptionLocated, UnsupportedEncodingException {
|
throws EaterException, UnsupportedEncodingException {
|
||||||
final InputStream is = url.openStream();
|
final InputStream is = url.openStream();
|
||||||
if (is == null)
|
if (is == null)
|
||||||
throw EaterExceptionLocated.located("Cannot open URL", s);
|
throw new EaterException("Cannot open URL", s);
|
||||||
|
|
||||||
return ReadLineReader.create(new InputStreamReader(is, charset), url.toString(), s.getLocation());
|
return ReadLineReader.create(new InputStreamReader(is, charset), url.toString(), s.getLocation());
|
||||||
}
|
}
|
||||||
|
@ -64,19 +64,19 @@ public abstract class Eater {
|
|||||||
return stringLocated;
|
return stringLocated;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void analyze(TContext context, TMemory memory) throws EaterExceptionLocated;
|
public abstract void analyze(TContext context, TMemory memory) throws EaterException;
|
||||||
|
|
||||||
public int getCurrentPosition() {
|
public int getCurrentPosition() {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected String eatAllToEnd() throws EaterExceptionLocated {
|
final protected String eatAllToEnd() throws EaterException {
|
||||||
final String result = stringLocated.getString().substring(i);
|
final String result = stringLocated.getString().substring(i);
|
||||||
i = stringLocated.length();
|
i = stringLocated.length();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public TValue eatExpression(TContext context, TMemory memory) throws EaterExceptionLocated {
|
final public TValue eatExpression(TContext context, TMemory memory) throws EaterException {
|
||||||
final char ch = peekChar();
|
final char ch = peekChar();
|
||||||
if (ch == '{' || ch == '[') {
|
if (ch == '{' || ch == '[') {
|
||||||
final String data = eatAllToEnd();
|
final String data = eatAllToEnd();
|
||||||
@ -89,22 +89,22 @@ public abstract class Eater {
|
|||||||
return tokenStack.getResult(getStringLocated(), context, memory);
|
return tokenStack.getResult(getStringLocated(), context, memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected TokenStack eatTokenStack() throws EaterExceptionLocated {
|
final protected TokenStack eatTokenStack() throws EaterException {
|
||||||
final TokenStack tokenStack = new TokenStack();
|
final TokenStack tokenStack = new TokenStack();
|
||||||
addIntoTokenStack(tokenStack, false);
|
addIntoTokenStack(tokenStack, false);
|
||||||
if (tokenStack.size() == 0)
|
if (tokenStack.size() == 0)
|
||||||
throw EaterExceptionLocated.located("Missing expression", stringLocated);
|
throw new EaterException("Missing expression", stringLocated);
|
||||||
|
|
||||||
return tokenStack;
|
return tokenStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected TValue eatExpressionStopAtColon(TContext context, TMemory memory) throws EaterExceptionLocated {
|
final protected TValue eatExpressionStopAtColon(TContext context, TMemory memory) throws EaterException {
|
||||||
final TokenStack tokenStack = new TokenStack();
|
final TokenStack tokenStack = new TokenStack();
|
||||||
addIntoTokenStack(tokenStack, true);
|
addIntoTokenStack(tokenStack, true);
|
||||||
return tokenStack.getResult(getStringLocated(), context, memory);
|
return tokenStack.getResult(getStringLocated(), context, memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected void addIntoTokenStack(TokenStack tokenStack, boolean stopAtColon) throws EaterExceptionLocated {
|
final protected void addIntoTokenStack(TokenStack tokenStack, boolean stopAtColon) throws EaterException {
|
||||||
Token lastToken = null;
|
Token lastToken = null;
|
||||||
while (true) {
|
while (true) {
|
||||||
final Token token = TokenType.eatOneToken(lastToken, this, stopAtColon);
|
final Token token = TokenType.eatOneToken(lastToken, this, stopAtColon);
|
||||||
@ -117,10 +117,10 @@ public abstract class Eater {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final public String eatAndGetQuotedString() throws EaterExceptionLocated {
|
final public String eatAndGetQuotedString() throws EaterException {
|
||||||
final char separator = peekChar();
|
final char separator = peekChar();
|
||||||
if (TLineType.isQuote(separator) == false)
|
if (TLineType.isQuote(separator) == false)
|
||||||
throw EaterExceptionLocated.located("quote10", stringLocated);
|
throw new EaterException("quote10", stringLocated);
|
||||||
|
|
||||||
checkAndEatChar(separator);
|
checkAndEatChar(separator);
|
||||||
final StringBuilder value = new StringBuilder();
|
final StringBuilder value = new StringBuilder();
|
||||||
@ -129,7 +129,7 @@ public abstract class Eater {
|
|||||||
return value.toString();
|
return value.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected String eatAndGetOptionalQuotedString() throws EaterExceptionLocated {
|
final protected String eatAndGetOptionalQuotedString() throws EaterException {
|
||||||
final char quote = peekChar();
|
final char quote = peekChar();
|
||||||
if (TLineType.isQuote(quote))
|
if (TLineType.isQuote(quote))
|
||||||
return eatAndGetQuotedString();
|
return eatAndGetQuotedString();
|
||||||
@ -141,7 +141,7 @@ public abstract class Eater {
|
|||||||
while (true) {
|
while (true) {
|
||||||
char ch = peekChar();
|
char ch = peekChar();
|
||||||
if (ch == 0)
|
if (ch == 0)
|
||||||
throw EaterExceptionLocated.located("until001", stringLocated);
|
throw new EaterException("until001", stringLocated);
|
||||||
|
|
||||||
if (level == 0 && (ch == ',' || ch == ')'))
|
if (level == 0 && (ch == ',' || ch == ')'))
|
||||||
return value.toString().trim();
|
return value.toString().trim();
|
||||||
@ -159,7 +159,7 @@ public abstract class Eater {
|
|||||||
// return value.toString();
|
// return value.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
final public String eatAndGetNumber() throws EaterExceptionLocated {
|
final public String eatAndGetNumber() throws EaterException {
|
||||||
final StringBuilder result = new StringBuilder();
|
final StringBuilder result = new StringBuilder();
|
||||||
while (true) {
|
while (true) {
|
||||||
final char ch = peekChar();
|
final char ch = peekChar();
|
||||||
@ -175,7 +175,7 @@ public abstract class Eater {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final public String eatAndGetSpaces() throws EaterExceptionLocated {
|
final public String eatAndGetSpaces() throws EaterException {
|
||||||
final StringBuilder result = new StringBuilder();
|
final StringBuilder result = new StringBuilder();
|
||||||
while (true) {
|
while (true) {
|
||||||
final char ch = peekChar();
|
final char ch = peekChar();
|
||||||
@ -186,19 +186,19 @@ public abstract class Eater {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected String eatAndGetVarname() throws EaterExceptionLocated {
|
final protected String eatAndGetVarname() throws EaterException {
|
||||||
final StringBuilder varname = new StringBuilder("" + eatOneChar());
|
final StringBuilder varname = new StringBuilder("" + eatOneChar());
|
||||||
if (TLineType.isLetterOrUnderscoreOrDollar(varname.charAt(0)) == false)
|
if (TLineType.isLetterOrUnderscoreOrDollar(varname.charAt(0)) == false)
|
||||||
throw EaterExceptionLocated.located("a002", stringLocated);
|
throw new EaterException("a002", stringLocated);
|
||||||
|
|
||||||
addUpToLastLetterOrUnderscoreOrDigit(varname);
|
addUpToLastLetterOrUnderscoreOrDigit(varname);
|
||||||
return varname.toString();
|
return varname.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected String eatAndGetFunctionName() throws EaterExceptionLocated {
|
final protected String eatAndGetFunctionName() throws EaterException {
|
||||||
final StringBuilder varname = new StringBuilder("" + eatOneChar());
|
final StringBuilder varname = new StringBuilder("" + eatOneChar());
|
||||||
if (TLineType.isLetterOrUnderscoreOrDollar(varname.charAt(0)) == false)
|
if (TLineType.isLetterOrUnderscoreOrDollar(varname.charAt(0)) == false)
|
||||||
throw EaterExceptionLocated.located("a003", stringLocated);
|
throw new EaterException("a003", stringLocated);
|
||||||
|
|
||||||
addUpToLastLetterOrUnderscoreOrDigit(varname);
|
addUpToLastLetterOrUnderscoreOrDigit(varname);
|
||||||
return varname.toString();
|
return varname.toString();
|
||||||
@ -246,14 +246,14 @@ public abstract class Eater {
|
|||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected void checkAndEatChar(char ch) throws EaterExceptionLocated {
|
final protected void checkAndEatChar(char ch) throws EaterException {
|
||||||
if (i >= stringLocated.length() || stringLocated.charAt(i) != ch)
|
if (i >= stringLocated.length() || stringLocated.charAt(i) != ch)
|
||||||
throw EaterExceptionLocated.located("a001", stringLocated);
|
throw new EaterException("a001", stringLocated);
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected boolean safeCheckAndEatChar(char ch) throws EaterExceptionLocated {
|
final protected boolean safeCheckAndEatChar(char ch) throws EaterException {
|
||||||
if (i >= stringLocated.length() || stringLocated.charAt(i) != ch)
|
if (i >= stringLocated.length() || stringLocated.charAt(i) != ch)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -261,7 +261,7 @@ public abstract class Eater {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected void optionallyEatChar(char ch) throws EaterExceptionLocated {
|
final protected void optionallyEatChar(char ch) throws EaterException {
|
||||||
if (i >= stringLocated.length() || stringLocated.charAt(i) != ch)
|
if (i >= stringLocated.length() || stringLocated.charAt(i) != ch)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ public abstract class Eater {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected void checkAndEatChar(String s) throws EaterExceptionLocated {
|
final protected void checkAndEatChar(String s) throws EaterException {
|
||||||
for (int j = 0; j < s.length(); j++)
|
for (int j = 0; j < s.length(); j++)
|
||||||
checkAndEatChar(s.charAt(j));
|
checkAndEatChar(s.charAt(j));
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ public abstract class Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final protected TFunctionImpl eatDeclareFunction(TContext context, TMemory memory, boolean unquoted,
|
final protected TFunctionImpl eatDeclareFunction(TContext context, TMemory memory, boolean unquoted,
|
||||||
StringLocated location, boolean allowNoParenthesis, TFunctionType type) throws EaterExceptionLocated {
|
StringLocated location, boolean allowNoParenthesis, TFunctionType type) throws EaterException {
|
||||||
final List<TFunctionArgument> args = new ArrayList<>();
|
final List<TFunctionArgument> args = new ArrayList<>();
|
||||||
final String functionName = eatAndGetFunctionName();
|
final String functionName = eatAndGetFunctionName();
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
@ -306,7 +306,7 @@ public abstract class Eater {
|
|||||||
if (allowNoParenthesis)
|
if (allowNoParenthesis)
|
||||||
return new TFunctionImpl(functionName, args, unquoted, type);
|
return new TFunctionImpl(functionName, args, unquoted, type);
|
||||||
|
|
||||||
throw EaterExceptionLocated.located("Missing opening parenthesis", stringLocated);
|
throw new EaterException("Missing opening parenthesis", stringLocated);
|
||||||
}
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
@ -331,7 +331,7 @@ public abstract class Eater {
|
|||||||
checkAndEatChar(")");
|
checkAndEatChar(")");
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
throw EaterExceptionLocated.located("Error in function definition", stringLocated);
|
throw new EaterException("Error in function definition", stringLocated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
@ -339,7 +339,7 @@ public abstract class Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final protected TFunctionImpl eatDeclareReturnFunctionWithOptionalReturn(TContext context, TMemory memory,
|
final protected TFunctionImpl eatDeclareReturnFunctionWithOptionalReturn(TContext context, TMemory memory,
|
||||||
boolean unquoted, StringLocated location) throws EaterExceptionLocated {
|
boolean unquoted, StringLocated location) throws EaterException {
|
||||||
final TFunctionImpl result = eatDeclareFunction(context, memory, unquoted, location, false,
|
final TFunctionImpl result = eatDeclareFunction(context, memory, unquoted, location, false,
|
||||||
TFunctionType.RETURN_FUNCTION);
|
TFunctionType.RETURN_FUNCTION);
|
||||||
if (peekChar() == 'r') {
|
if (peekChar() == 'r') {
|
||||||
@ -357,7 +357,7 @@ public abstract class Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final protected TFunctionImpl eatDeclareProcedure(TContext context, TMemory memory, boolean unquoted,
|
final protected TFunctionImpl eatDeclareProcedure(TContext context, TMemory memory, boolean unquoted,
|
||||||
StringLocated location) throws EaterExceptionLocated {
|
StringLocated location) throws EaterException {
|
||||||
final TFunctionImpl result = eatDeclareFunction(context, memory, unquoted, location, false,
|
final TFunctionImpl result = eatDeclareFunction(context, memory, unquoted, location, false,
|
||||||
TFunctionType.PROCEDURE);
|
TFunctionType.PROCEDURE);
|
||||||
return result;
|
return result;
|
||||||
|
@ -44,7 +44,7 @@ public class EaterAffectation extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!");
|
checkAndEatChar("!");
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
|
@ -44,7 +44,7 @@ public class EaterAffectationDefine extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!define");
|
checkAndEatChar("!define");
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
|
@ -44,7 +44,7 @@ public class EaterAssert extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!assert");
|
checkAndEatChar("!assert");
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
@ -55,9 +55,9 @@ public class EaterAssert extends Eater {
|
|||||||
if (ch == ':') {
|
if (ch == ':') {
|
||||||
checkAndEatChar(':');
|
checkAndEatChar(':');
|
||||||
final TValue message = eatExpression(context, memory);
|
final TValue message = eatExpression(context, memory);
|
||||||
throw EaterExceptionLocated.located("Assertion error : " + message.toString(), getStringLocated());
|
throw new EaterException("Assertion error : " + message.toString(), getStringLocated());
|
||||||
}
|
}
|
||||||
throw EaterExceptionLocated.located("Assertion error", getStringLocated());
|
throw new EaterException("Assertion error", getStringLocated());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public class EaterDeclareProcedure extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!");
|
checkAndEatChar("!");
|
||||||
boolean unquoted = false;
|
boolean unquoted = false;
|
||||||
|
@ -48,7 +48,7 @@ public class EaterDeclareReturnFunction extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!");
|
checkAndEatChar("!");
|
||||||
boolean unquoted = false;
|
boolean unquoted = false;
|
||||||
|
@ -43,7 +43,7 @@ public class EaterDumpMemory extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!dump_memory");
|
checkAndEatChar("!dump_memory");
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
|
@ -46,7 +46,7 @@ public class EaterElseIf extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!elseif");
|
checkAndEatChar("!elseif");
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
|
@ -38,22 +38,14 @@ import java.util.Objects;
|
|||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
|
|
||||||
public class EaterExceptionLocated extends Exception {
|
public class EaterException extends Exception {
|
||||||
|
|
||||||
private final String message;
|
private final String message;
|
||||||
private final StringLocated location;
|
private final StringLocated location;
|
||||||
|
|
||||||
private EaterExceptionLocated(String message, StringLocated location) {
|
public EaterException(String message, StringLocated location) {
|
||||||
this.message = message;
|
this.message = Objects.requireNonNull(message);
|
||||||
this.location = location;
|
this.location = Objects.requireNonNull(location);
|
||||||
}
|
|
||||||
|
|
||||||
public static EaterExceptionLocated located(String message, StringLocated location) {
|
|
||||||
return new EaterExceptionLocated(message, Objects.requireNonNull(location));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EaterExceptionLocated unlocated(String message, StringLocated location) {
|
|
||||||
return new EaterExceptionLocated(message, Objects.requireNonNull(location));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getMessage() {
|
public final String getMessage() {
|
@ -48,7 +48,7 @@ public class EaterForeach extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!foreach");
|
checkAndEatChar("!foreach");
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
|
@ -58,7 +58,7 @@ public class EaterFunctionCall extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipUntilChar('(');
|
skipUntilChar('(');
|
||||||
checkAndEatChar('(');
|
checkAndEatChar('(');
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
@ -119,10 +119,9 @@ public class EaterFunctionCall extends Eater {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (unquoted) {
|
if (unquoted) {
|
||||||
throw EaterExceptionLocated.located("unquoted function/procedure cannot use expression.",
|
throw new EaterException("unquoted function/procedure cannot use expression.", getStringLocated());
|
||||||
getStringLocated());
|
|
||||||
}
|
}
|
||||||
throw EaterExceptionLocated.located("call001", getStringLocated());
|
throw new EaterException("call001", getStringLocated());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +133,7 @@ public class EaterFunctionCall extends Eater {
|
|||||||
return Collections.unmodifiableMap(namedArguments);
|
return Collections.unmodifiableMap(namedArguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getEndOfLine() throws EaterExceptionLocated {
|
public final String getEndOfLine() throws EaterException {
|
||||||
return this.eatAllToEnd();
|
return this.eatAllToEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ public class EaterIf extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!if");
|
checkAndEatChar("!if");
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
|
@ -48,7 +48,7 @@ public class EaterIfdef extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!ifdef");
|
checkAndEatChar("!ifdef");
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
|
@ -46,7 +46,7 @@ public class EaterIfndef extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!ifndef");
|
checkAndEatChar("!ifndef");
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
|
@ -45,7 +45,7 @@ public class EaterImport extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!import");
|
checkAndEatChar("!import");
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
|
@ -47,7 +47,7 @@ public class EaterInclude extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!include");
|
checkAndEatChar("!include");
|
||||||
final char peekChar = peekChar();
|
final char peekChar = peekChar();
|
||||||
|
@ -45,7 +45,7 @@ public class EaterIncludeDef extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!includedef");
|
checkAndEatChar("!includedef");
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
|
@ -45,7 +45,7 @@ public class EaterIncludesub extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!includesub");
|
checkAndEatChar("!includesub");
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
|
@ -45,7 +45,7 @@ public class EaterLegacyDefine extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!define");
|
checkAndEatChar("!define");
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
|
@ -45,7 +45,7 @@ public class EaterLegacyDefineLong extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!definelong");
|
checkAndEatChar("!definelong");
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
|
@ -44,7 +44,7 @@ public class EaterLog extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!log");
|
checkAndEatChar("!log");
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
|
@ -46,7 +46,7 @@ public class EaterReturn extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!return");
|
checkAndEatChar("!return");
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
|
@ -45,13 +45,13 @@ public class EaterStartsub extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!startsub");
|
checkAndEatChar("!startsub");
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
this.subname = eatAllToEnd();
|
this.subname = eatAllToEnd();
|
||||||
if (this.subname.matches("\\w+") == false)
|
if (this.subname.matches("\\w+") == false)
|
||||||
throw EaterExceptionLocated.located("Bad sub name", getStringLocated());
|
throw new EaterException("Bad sub name", getStringLocated());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ public class EaterTheme extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!theme");
|
checkAndEatChar("!theme");
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
@ -85,7 +85,7 @@ public class EaterTheme extends Eater {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ReadLine getTheme() throws EaterExceptionLocated {
|
public final ReadLine getTheme() throws EaterException {
|
||||||
if (from == null) {
|
if (from == null) {
|
||||||
try {
|
try {
|
||||||
final ReadLine reader = ThemeUtils.getReaderTheme(realName);
|
final ReadLine reader = ThemeUtils.getReaderTheme(realName);
|
||||||
@ -101,24 +101,24 @@ public class EaterTheme extends Eater {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Logme.error(e);
|
Logme.error(e);
|
||||||
}
|
}
|
||||||
throw EaterExceptionLocated.located("Cannot load " + realName, getStringLocated());
|
throw new EaterException("Cannot load " + realName, getStringLocated());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (from.startsWith("<") && from.endsWith(">")) {
|
if (from.startsWith("<") && from.endsWith(">")) {
|
||||||
final ReadLine reader = ThemeUtils.getReaderTheme(realName, from);
|
final ReadLine reader = ThemeUtils.getReaderTheme(realName, from);
|
||||||
if (reader == null)
|
if (reader == null)
|
||||||
throw EaterExceptionLocated.located("No such theme " + realName + " in " + from, getStringLocated());
|
throw new EaterException("No such theme " + realName + " in " + from, getStringLocated());
|
||||||
return reader;
|
return reader;
|
||||||
} else if (from.startsWith("http://") || from.startsWith("https://")) {
|
} else if (from.startsWith("http://") || from.startsWith("https://")) {
|
||||||
final SURL url = SURL.create(ThemeUtils.getFullPath(from, realName));
|
final SURL url = SURL.create(ThemeUtils.getFullPath(from, realName));
|
||||||
if (url == null)
|
if (url == null)
|
||||||
throw EaterExceptionLocated.located("Cannot open URL", getStringLocated());
|
throw new EaterException("Cannot open URL", getStringLocated());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return PreprocessorUtils.getReaderInclude(url, getStringLocated(), UTF_8);
|
return PreprocessorUtils.getReaderInclude(url, getStringLocated(), UTF_8);
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
Logme.error(e);
|
Logme.error(e);
|
||||||
throw EaterExceptionLocated.located("Cannot decode charset", getStringLocated());
|
throw new EaterException("Cannot decode charset", getStringLocated());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,12 +126,12 @@ public class EaterTheme extends Eater {
|
|||||||
final FileWithSuffix file = context.getFileWithSuffix(from, realName);
|
final FileWithSuffix file = context.getFileWithSuffix(from, realName);
|
||||||
final Reader tmp = file.getReader(UTF_8);
|
final Reader tmp = file.getReader(UTF_8);
|
||||||
if (tmp == null)
|
if (tmp == null)
|
||||||
throw EaterExceptionLocated.located("No such theme " + realName, getStringLocated());
|
throw new EaterException("No such theme " + realName, getStringLocated());
|
||||||
|
|
||||||
return ReadLineReader.create(tmp, "theme " + realName);
|
return ReadLineReader.create(tmp, "theme " + realName);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Logme.error(e);
|
Logme.error(e);
|
||||||
throw EaterExceptionLocated.located("Cannot load " + realName, getStringLocated());
|
throw new EaterException("Cannot load " + realName, getStringLocated());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public class EaterUndef extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!undef");
|
checkAndEatChar("!undef");
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
|
@ -46,7 +46,7 @@ public class EaterWhile extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
checkAndEatChar("!while");
|
checkAndEatChar("!while");
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
|
@ -61,7 +61,7 @@ public class ExecutionContextWhile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TValue conditionValue(StringLocated location, TContext context, TMemory memory)
|
public TValue conditionValue(StringLocated location, TContext context, TMemory memory)
|
||||||
throws EaterExceptionLocated {
|
throws EaterException {
|
||||||
return whileExpression.getResult(location, context, memory);
|
return whileExpression.getResult(location, context, memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ public abstract class ExecutionContexts {
|
|||||||
return allForeachs.pollLast();
|
return allForeachs.pollLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean areAllIfOk(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public boolean areAllIfOk(TContext context, TMemory memory) throws EaterException {
|
||||||
for (ExecutionContextIf conditionalContext : allIfs)
|
for (ExecutionContextIf conditionalContext : allIfs)
|
||||||
if (conditionalContext.conditionIsOkHere() == false)
|
if (conditionalContext.conditionIsOkHere() == false)
|
||||||
return false;
|
return false;
|
||||||
|
@ -95,9 +95,9 @@ public class FunctionsSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void executeLegacyDefine(TContext context, TMemory memory, StringLocated s)
|
public void executeLegacyDefine(TContext context, TMemory memory, StringLocated s)
|
||||||
throws EaterExceptionLocated {
|
throws EaterException {
|
||||||
if (this.pendingFunction != null)
|
if (this.pendingFunction != null)
|
||||||
throw EaterExceptionLocated.located("already0048", s);
|
throw new EaterException("already0048", s);
|
||||||
|
|
||||||
final EaterLegacyDefine legacyDefine = new EaterLegacyDefine(s);
|
final EaterLegacyDefine legacyDefine = new EaterLegacyDefine(s);
|
||||||
legacyDefine.analyze(context, memory);
|
legacyDefine.analyze(context, memory);
|
||||||
@ -107,9 +107,9 @@ public class FunctionsSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void executeLegacyDefineLong(TContext context, TMemory memory, StringLocated s)
|
public void executeLegacyDefineLong(TContext context, TMemory memory, StringLocated s)
|
||||||
throws EaterExceptionLocated {
|
throws EaterException {
|
||||||
if (this.pendingFunction != null)
|
if (this.pendingFunction != null)
|
||||||
throw EaterExceptionLocated.located("already0068", s);
|
throw new EaterException("already0068", s);
|
||||||
|
|
||||||
final EaterLegacyDefineLong legacyDefineLong = new EaterLegacyDefineLong(s);
|
final EaterLegacyDefineLong legacyDefineLong = new EaterLegacyDefineLong(s);
|
||||||
legacyDefineLong.analyze(context, memory);
|
legacyDefineLong.analyze(context, memory);
|
||||||
@ -117,9 +117,9 @@ public class FunctionsSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void executeDeclareReturnFunction(TContext context, TMemory memory, StringLocated s)
|
public void executeDeclareReturnFunction(TContext context, TMemory memory, StringLocated s)
|
||||||
throws EaterExceptionLocated {
|
throws EaterException {
|
||||||
if (this.pendingFunction != null)
|
if (this.pendingFunction != null)
|
||||||
throw EaterExceptionLocated.located("already0068", s);
|
throw new EaterException("already0068", s);
|
||||||
|
|
||||||
final EaterDeclareReturnFunction declareFunction = new EaterDeclareReturnFunction(s);
|
final EaterDeclareReturnFunction declareFunction = new EaterDeclareReturnFunction(s);
|
||||||
declareFunction.analyze(context, memory);
|
declareFunction.analyze(context, memory);
|
||||||
@ -127,7 +127,7 @@ public class FunctionsSet {
|
|||||||
final TFunctionSignature declaredSignature = declareFunction.getFunction().getSignature();
|
final TFunctionSignature declaredSignature = declareFunction.getFunction().getSignature();
|
||||||
final TFunction previous = this.functions.get(declaredSignature);
|
final TFunction previous = this.functions.get(declaredSignature);
|
||||||
if (previous != null && (finalFlag || this.functionsFinal.contains(declaredSignature)))
|
if (previous != null && (finalFlag || this.functionsFinal.contains(declaredSignature)))
|
||||||
throw EaterExceptionLocated.located("This function is already defined", s);
|
throw new EaterException("This function is already defined", s);
|
||||||
|
|
||||||
if (finalFlag)
|
if (finalFlag)
|
||||||
this.functionsFinal.add(declaredSignature);
|
this.functionsFinal.add(declaredSignature);
|
||||||
@ -140,9 +140,9 @@ public class FunctionsSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void executeDeclareProcedure(TContext context, TMemory memory, StringLocated s)
|
public void executeDeclareProcedure(TContext context, TMemory memory, StringLocated s)
|
||||||
throws EaterExceptionLocated {
|
throws EaterException {
|
||||||
if (this.pendingFunction != null)
|
if (this.pendingFunction != null)
|
||||||
throw EaterExceptionLocated.located("already0068", s);
|
throw new EaterException("already0068", s);
|
||||||
|
|
||||||
final EaterDeclareProcedure declareFunction = new EaterDeclareProcedure(s);
|
final EaterDeclareProcedure declareFunction = new EaterDeclareProcedure(s);
|
||||||
declareFunction.analyze(context, memory);
|
declareFunction.analyze(context, memory);
|
||||||
@ -150,7 +150,7 @@ public class FunctionsSet {
|
|||||||
final TFunctionSignature declaredSignature = declareFunction.getFunction().getSignature();
|
final TFunctionSignature declaredSignature = declareFunction.getFunction().getSignature();
|
||||||
final TFunction previous = this.functions.get(declaredSignature);
|
final TFunction previous = this.functions.get(declaredSignature);
|
||||||
if (previous != null && (finalFlag || this.functionsFinal.contains(declaredSignature)))
|
if (previous != null && (finalFlag || this.functionsFinal.contains(declaredSignature)))
|
||||||
throw EaterExceptionLocated.located("This function is already defined", s);
|
throw new EaterException("This function is already defined", s);
|
||||||
|
|
||||||
if (finalFlag)
|
if (finalFlag)
|
||||||
this.functionsFinal.add(declaredSignature);
|
this.functionsFinal.add(declaredSignature);
|
||||||
|
@ -43,7 +43,7 @@ public class StringEater extends Eater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated {
|
public void analyze(TContext context, TMemory memory) throws EaterException {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ public class TContext {
|
|||||||
public Knowledge asKnowledge(final TMemory memory, final LineLocation location) {
|
public Knowledge asKnowledge(final TMemory memory, final LineLocation location) {
|
||||||
return new Knowledge() {
|
return new Knowledge() {
|
||||||
|
|
||||||
public TValue getVariable(String name) throws EaterExceptionLocated {
|
public TValue getVariable(String name) throws EaterException {
|
||||||
if (name.contains(".") || name.contains("[")) {
|
if (name.contains(".") || name.contains("[")) {
|
||||||
final TValue result = fromJson(memory, name, location);
|
final TValue result = fromJson(memory, name, location);
|
||||||
return result;
|
return result;
|
||||||
@ -250,7 +250,7 @@ public class TContext {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private TValue fromJson(TMemory memory, String name, LineLocation location) throws EaterExceptionLocated {
|
private TValue fromJson(TMemory memory, String name, LineLocation location) throws EaterException {
|
||||||
final String result = applyFunctionsAndVariables(memory, new StringLocated(name, location));
|
final String result = applyFunctionsAndVariables(memory, new StringLocated(name, location));
|
||||||
try {
|
try {
|
||||||
final JsonValue json = Json.parse(result);
|
final JsonValue json = Json.parse(result);
|
||||||
@ -279,7 +279,7 @@ public class TContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TValue executeLines(TMemory memory, List<StringLocated> body, TFunctionType ftype, boolean modeSpecial)
|
public TValue executeLines(TMemory memory, List<StringLocated> body, TFunctionType ftype, boolean modeSpecial)
|
||||||
throws EaterExceptionLocated {
|
throws EaterException {
|
||||||
final CodeIterator it = buildCodeIterator(memory, body);
|
final CodeIterator it = buildCodeIterator(memory, body);
|
||||||
|
|
||||||
StringLocated s = null;
|
StringLocated s = null;
|
||||||
@ -295,7 +295,7 @@ public class TContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void executeLinesInternal(TMemory memory, List<StringLocated> body, TFunctionType ftype)
|
private void executeLinesInternal(TMemory memory, List<StringLocated> body, TFunctionType ftype)
|
||||||
throws EaterExceptionLocated {
|
throws EaterException {
|
||||||
final CodeIterator it = buildCodeIterator(memory, body);
|
final CodeIterator it = buildCodeIterator(memory, body);
|
||||||
|
|
||||||
StringLocated s = null;
|
StringLocated s = null;
|
||||||
@ -307,20 +307,20 @@ public class TContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TValue executeOneLineSafe(TMemory memory, StringLocated s, TFunctionType ftype, boolean modeSpecial)
|
private TValue executeOneLineSafe(TMemory memory, StringLocated s, TFunctionType ftype, boolean modeSpecial)
|
||||||
throws EaterExceptionLocated {
|
throws EaterException {
|
||||||
try {
|
try {
|
||||||
this.debug.add(s);
|
this.debug.add(s);
|
||||||
return executeOneLineNotSafe(memory, s, ftype, modeSpecial);
|
return executeOneLineNotSafe(memory, s, ftype, modeSpecial);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (e instanceof EaterExceptionLocated)
|
if (e instanceof EaterException)
|
||||||
throw (EaterExceptionLocated) e;
|
throw (EaterException) e;
|
||||||
Logme.error(e);
|
Logme.error(e);
|
||||||
throw EaterExceptionLocated.located("Fatal parsing error", s);
|
throw new EaterException("Fatal parsing error", s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TValue executeOneLineNotSafe(TMemory memory, StringLocated s, TFunctionType ftype, boolean modeSpecial)
|
private TValue executeOneLineNotSafe(TMemory memory, StringLocated s, TFunctionType ftype, boolean modeSpecial)
|
||||||
throws EaterExceptionLocated {
|
throws EaterException {
|
||||||
final TLineType type = s.getType();
|
final TLineType type = s.getType();
|
||||||
|
|
||||||
if (type == TLineType.INCLUDESUB) {
|
if (type == TLineType.INCLUDESUB) {
|
||||||
@ -375,11 +375,11 @@ public class TContext {
|
|||||||
} else if (s.getString().matches("^\\s+$")) {
|
} else if (s.getString().matches("^\\s+$")) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
throw EaterExceptionLocated.located("Compile Error " + ftype + " " + type, s);
|
throw new EaterException("Compile Error " + ftype + " " + type, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPlain(TMemory memory, StringLocated s) throws EaterExceptionLocated {
|
private void addPlain(TMemory memory, StringLocated s) throws EaterException {
|
||||||
final StringLocated tmp[] = applyFunctionsAndVariablesInternal(memory, s);
|
final StringLocated tmp[] = applyFunctionsAndVariablesInternal(memory, s);
|
||||||
if (tmp != null) {
|
if (tmp != null) {
|
||||||
if (pendingAdd != null) {
|
if (pendingAdd != null) {
|
||||||
@ -392,31 +392,31 @@ public class TContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void simulatePlain(TMemory memory, StringLocated s) throws EaterExceptionLocated {
|
private void simulatePlain(TMemory memory, StringLocated s) throws EaterException {
|
||||||
final StringLocated ignored[] = applyFunctionsAndVariablesInternal(memory, s);
|
final StringLocated ignored[] = applyFunctionsAndVariablesInternal(memory, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeAffectationDefine(TMemory memory, StringLocated s) throws EaterExceptionLocated {
|
private void executeAffectationDefine(TMemory memory, StringLocated s) throws EaterException {
|
||||||
new EaterAffectationDefine(s).analyze(this, memory);
|
new EaterAffectationDefine(s).analyze(this, memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeDumpMemory(TMemory memory, StringLocated s) throws EaterExceptionLocated {
|
private void executeDumpMemory(TMemory memory, StringLocated s) throws EaterException {
|
||||||
final EaterDumpMemory condition = new EaterDumpMemory(s);
|
final EaterDumpMemory condition = new EaterDumpMemory(s);
|
||||||
condition.analyze(this, memory);
|
condition.analyze(this, memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeAssert(TMemory memory, StringLocated s) throws EaterExceptionLocated {
|
private void executeAssert(TMemory memory, StringLocated s) throws EaterException {
|
||||||
final EaterAssert condition = new EaterAssert(s);
|
final EaterAssert condition = new EaterAssert(s);
|
||||||
condition.analyze(this, memory);
|
condition.analyze(this, memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeUndef(TMemory memory, StringLocated s) throws EaterExceptionLocated {
|
private void executeUndef(TMemory memory, StringLocated s) throws EaterException {
|
||||||
final EaterUndef undef = new EaterUndef(s);
|
final EaterUndef undef = new EaterUndef(s);
|
||||||
undef.analyze(this, memory);
|
undef.analyze(this, memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
private StringLocated[] applyFunctionsAndVariablesInternal(TMemory memory, StringLocated located)
|
private StringLocated[] applyFunctionsAndVariablesInternal(TMemory memory, StringLocated located)
|
||||||
throws EaterExceptionLocated {
|
throws EaterException {
|
||||||
if (memory.isEmpty() && functionsSet.size() == 0)
|
if (memory.isEmpty() && functionsSet.size() == 0)
|
||||||
return new StringLocated[] { located };
|
return new StringLocated[] { located };
|
||||||
|
|
||||||
@ -434,7 +434,7 @@ public class TContext {
|
|||||||
|
|
||||||
private String pendingAdd = null;
|
private String pendingAdd = null;
|
||||||
|
|
||||||
public String applyFunctionsAndVariables(TMemory memory, final StringLocated str) throws EaterExceptionLocated {
|
public String applyFunctionsAndVariables(TMemory memory, final StringLocated str) throws EaterException {
|
||||||
// https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore%E2%80%93Horspool_algorithm
|
// https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore%E2%80%93Horspool_algorithm
|
||||||
// https://stackoverflow.com/questions/1326682/java-replacing-multiple-different-substring-in-a-string-at-once-or-in-the-most
|
// https://stackoverflow.com/questions/1326682/java-replacing-multiple-different-substring-in-a-string-at-once-or-in-the-most
|
||||||
// https://en.wikipedia.org/wiki/String-searching_algorithm
|
// https://en.wikipedia.org/wiki/String-searching_algorithm
|
||||||
@ -456,7 +456,7 @@ public class TContext {
|
|||||||
call.getNamedArguments().keySet());
|
call.getNamedArguments().keySet());
|
||||||
final TFunction function = functionsSet.getFunctionSmart(signature);
|
final TFunction function = functionsSet.getFunctionSmart(signature);
|
||||||
if (function == null)
|
if (function == null)
|
||||||
throw EaterExceptionLocated.located("Function not found " + presentFunction, str);
|
throw new EaterException("Function not found " + presentFunction, str);
|
||||||
|
|
||||||
if (function.getFunctionType() == TFunctionType.PROCEDURE) {
|
if (function.getFunctionType() == TFunctionType.PROCEDURE) {
|
||||||
this.pendingAdd = result.toString();
|
this.pendingAdd = result.toString();
|
||||||
@ -494,11 +494,11 @@ public class TContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void executeVoid3(StringLocated location, TMemory memory, TFunction function, EaterFunctionCall call)
|
private void executeVoid3(StringLocated location, TMemory memory, TFunction function, EaterFunctionCall call)
|
||||||
throws EaterExceptionLocated {
|
throws EaterException {
|
||||||
function.executeProcedureInternal(this, memory, location, call.getValues(), call.getNamedArguments());
|
function.executeProcedureInternal(this, memory, location, call.getValues(), call.getNamedArguments());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeImport(TMemory memory, StringLocated s) throws EaterExceptionLocated {
|
private void executeImport(TMemory memory, StringLocated s) throws EaterException {
|
||||||
final EaterImport _import = new EaterImport(s.getTrimmed());
|
final EaterImport _import = new EaterImport(s.getTrimmed());
|
||||||
_import.analyze(this, memory);
|
_import.analyze(this, memory);
|
||||||
|
|
||||||
@ -511,13 +511,13 @@ public class TContext {
|
|||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Logme.error(e);
|
Logme.error(e);
|
||||||
throw EaterExceptionLocated.located("Cannot import " + e.getMessage(), s);
|
throw new EaterException("Cannot import " + e.getMessage(), s);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw EaterExceptionLocated.located("Cannot import", s);
|
throw new EaterException("Cannot import", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeLog(TMemory memory, StringLocated s) throws EaterExceptionLocated {
|
private void executeLog(TMemory memory, StringLocated s) throws EaterException {
|
||||||
final EaterLog log = new EaterLog(s.getTrimmed());
|
final EaterLog log = new EaterLog(s.getTrimmed());
|
||||||
log.analyze(this, memory);
|
log.analyze(this, memory);
|
||||||
}
|
}
|
||||||
@ -529,7 +529,7 @@ public class TContext {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeIncludesub(TMemory memory, StringLocated s) throws EaterExceptionLocated {
|
private void executeIncludesub(TMemory memory, StringLocated s) throws EaterException {
|
||||||
ImportedFiles saveImportedFiles = null;
|
ImportedFiles saveImportedFiles = null;
|
||||||
try {
|
try {
|
||||||
final EaterIncludesub include = new EaterIncludesub(s.getTrimmed());
|
final EaterIncludesub include = new EaterIncludesub(s.getTrimmed());
|
||||||
@ -547,7 +547,7 @@ public class TContext {
|
|||||||
this.importedFiles = this.importedFiles.withCurrentDir(f2.getParentFile());
|
this.importedFiles = this.importedFiles.withCurrentDir(f2.getParentFile());
|
||||||
final Reader reader = f2.getReader(charset);
|
final Reader reader = f2.getReader(charset);
|
||||||
if (reader == null)
|
if (reader == null)
|
||||||
throw EaterExceptionLocated.located("cannot include " + what, s);
|
throw new EaterException("cannot include " + what, s);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ReadLine readerline = ReadLineReader.create(reader, what, s.getLocation());
|
ReadLine readerline = ReadLineReader.create(reader, what, s.getLocation());
|
||||||
@ -559,14 +559,14 @@ public class TContext {
|
|||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Logme.error(e);
|
Logme.error(e);
|
||||||
throw EaterExceptionLocated.located("cannot include " + what, s);
|
throw new EaterException("cannot include " + what, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sub == null)
|
if (sub == null)
|
||||||
sub = subs.get(what);
|
sub = subs.get(what);
|
||||||
|
|
||||||
if (sub == null)
|
if (sub == null)
|
||||||
throw EaterExceptionLocated.located("cannot include " + what, s);
|
throw new EaterException("cannot include " + what, s);
|
||||||
|
|
||||||
executeLinesInternal(memory, sub.lines(), null);
|
executeLinesInternal(memory, sub.lines(), null);
|
||||||
} finally {
|
} finally {
|
||||||
@ -576,7 +576,7 @@ public class TContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeIncludeDef(TMemory memory, StringLocated s) throws EaterExceptionLocated {
|
private void executeIncludeDef(TMemory memory, StringLocated s) throws EaterException {
|
||||||
final EaterIncludeDef include = new EaterIncludeDef(s.getTrimmed());
|
final EaterIncludeDef include = new EaterIncludeDef(s.getTrimmed());
|
||||||
include.analyze(this, memory);
|
include.analyze(this, memory);
|
||||||
final String definitionName = include.getLocation();
|
final String definitionName = include.getLocation();
|
||||||
@ -595,7 +595,7 @@ public class TContext {
|
|||||||
} while (true);
|
} while (true);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Logme.error(e);
|
Logme.error(e);
|
||||||
throw EaterExceptionLocated.located("" + e, s);
|
throw new EaterException("" + e, s);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
reader2.close();
|
reader2.close();
|
||||||
@ -605,12 +605,12 @@ public class TContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeTheme(TMemory memory, StringLocated s) throws EaterExceptionLocated {
|
private void executeTheme(TMemory memory, StringLocated s) throws EaterException {
|
||||||
final EaterTheme eater = new EaterTheme(s.getTrimmed(), importedFiles);
|
final EaterTheme eater = new EaterTheme(s.getTrimmed(), importedFiles);
|
||||||
eater.analyze(this, memory);
|
eater.analyze(this, memory);
|
||||||
final ReadLine reader = eater.getTheme();
|
final ReadLine reader = eater.getTheme();
|
||||||
if (reader == null)
|
if (reader == null)
|
||||||
throw EaterExceptionLocated.located("No such theme " + eater.getName(), s);
|
throw new EaterException("No such theme " + eater.getName(), s);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final List<StringLocated> body = new ArrayList<>();
|
final List<StringLocated> body = new ArrayList<>();
|
||||||
@ -624,7 +624,7 @@ public class TContext {
|
|||||||
} while (true);
|
} while (true);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Logme.error(e);
|
Logme.error(e);
|
||||||
throw EaterExceptionLocated.located("Error reading theme " + e, s);
|
throw new EaterException("Error reading theme " + e, s);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
reader.close();
|
reader.close();
|
||||||
@ -634,7 +634,7 @@ public class TContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeInclude(TMemory memory, StringLocated s) throws EaterExceptionLocated {
|
private void executeInclude(TMemory memory, StringLocated s) throws EaterException {
|
||||||
final EaterInclude include = new EaterInclude(s.getTrimmed());
|
final EaterInclude include = new EaterInclude(s.getTrimmed());
|
||||||
include.analyze(this, memory);
|
include.analyze(this, memory);
|
||||||
String location = include.getWhat();
|
String location = include.getWhat();
|
||||||
@ -652,7 +652,7 @@ public class TContext {
|
|||||||
if (location.startsWith("http://") || location.startsWith("https://")) {
|
if (location.startsWith("http://") || location.startsWith("https://")) {
|
||||||
final SURL url = SURL.create(location);
|
final SURL url = SURL.create(location);
|
||||||
if (url == null)
|
if (url == null)
|
||||||
throw EaterExceptionLocated.located("Cannot open URL", s);
|
throw new EaterException("Cannot open URL", s);
|
||||||
|
|
||||||
reader = PreprocessorUtils.getReaderIncludeUrl(url, s, suf, charset);
|
reader = PreprocessorUtils.getReaderIncludeUrl(url, s, suf, charset);
|
||||||
} else if (location.startsWith("<") && location.endsWith(">")) {
|
} else if (location.startsWith("<") && location.endsWith(">")) {
|
||||||
@ -668,14 +668,14 @@ public class TContext {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (strategy == PreprocessorIncludeStrategy.ONCE && filesUsedCurrent.contains(f2))
|
if (strategy == PreprocessorIncludeStrategy.ONCE && filesUsedCurrent.contains(f2))
|
||||||
throw EaterExceptionLocated.located("This file has already been included", s);
|
throw new EaterException("This file has already been included", s);
|
||||||
|
|
||||||
if (StartDiagramExtractReader.containsStartDiagram(f2, s, charset)) {
|
if (StartDiagramExtractReader.containsStartDiagram(f2, s, charset)) {
|
||||||
reader = StartDiagramExtractReader.build(f2, s, charset);
|
reader = StartDiagramExtractReader.build(f2, s, charset);
|
||||||
} else {
|
} else {
|
||||||
final Reader tmp = f2.getReader(charset);
|
final Reader tmp = f2.getReader(charset);
|
||||||
if (tmp == null)
|
if (tmp == null)
|
||||||
throw EaterExceptionLocated.located("Cannot include file", s);
|
throw new EaterException("Cannot include file", s);
|
||||||
|
|
||||||
reader = ReadLineReader.create(tmp, location, s.getLocation());
|
reader = ReadLineReader.create(tmp, location, s.getLocation());
|
||||||
}
|
}
|
||||||
@ -704,7 +704,7 @@ public class TContext {
|
|||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Logme.error(e);
|
Logme.error(e);
|
||||||
throw EaterExceptionLocated.located("cannot include " + e, s);
|
throw new EaterException("cannot include " + e, s);
|
||||||
} finally {
|
} finally {
|
||||||
if (reader != null) {
|
if (reader != null) {
|
||||||
try {
|
try {
|
||||||
@ -715,7 +715,7 @@ public class TContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw EaterExceptionLocated.located("cannot include " + location, s);
|
throw new EaterException("cannot include " + location, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLegacyDefine(String functionName) {
|
public boolean isLegacyDefine(String functionName) {
|
||||||
|
@ -50,10 +50,10 @@ public interface TFunction {
|
|||||||
public TFunctionType getFunctionType();
|
public TFunctionType getFunctionType();
|
||||||
|
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> args,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> args,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated;
|
Map<String, TValue> named) throws EaterException;
|
||||||
|
|
||||||
public void executeProcedureInternal(TContext context, TMemory memory, StringLocated location, List<TValue> args,
|
public void executeProcedureInternal(TContext context, TMemory memory, StringLocated location, List<TValue> args,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated;
|
Map<String, TValue> named) throws EaterException;
|
||||||
|
|
||||||
public boolean isUnquoted();
|
public boolean isUnquoted();
|
||||||
|
|
||||||
|
@ -121,19 +121,18 @@ public class TFunctionImpl implements TFunction {
|
|||||||
return "FUNCTION " + signature + " " + args;
|
return "FUNCTION " + signature + " " + args;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBody(StringLocated s) throws EaterExceptionLocated {
|
public void addBody(StringLocated s) throws EaterException {
|
||||||
body.add(s);
|
body.add(s);
|
||||||
if (s.getType() == TLineType.RETURN) {
|
if (s.getType() == TLineType.RETURN) {
|
||||||
this.containsReturn = true;
|
this.containsReturn = true;
|
||||||
if (functionType == TFunctionType.PROCEDURE)
|
if (functionType == TFunctionType.PROCEDURE)
|
||||||
throw EaterExceptionLocated
|
throw new EaterException("A procedure cannot have !return directive. Declare it as a function instead ?", s);
|
||||||
.located("A procedure cannot have !return directive. Declare it as a function instead ?", s);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executeProcedureInternal(TContext context, TMemory memory, StringLocated location, List<TValue> args,
|
public void executeProcedureInternal(TContext context, TMemory memory, StringLocated location, List<TValue> args,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
if (functionType != TFunctionType.PROCEDURE && functionType != TFunctionType.LEGACY_DEFINELONG)
|
if (functionType != TFunctionType.PROCEDURE && functionType != TFunctionType.LEGACY_DEFINELONG)
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
|
|
||||||
@ -143,24 +142,23 @@ public class TFunctionImpl implements TFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> args,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> args,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
if (functionType == TFunctionType.LEGACY_DEFINE)
|
if (functionType == TFunctionType.LEGACY_DEFINE)
|
||||||
return executeReturnLegacyDefine(location.getLocation(), context, memory, args);
|
return executeReturnLegacyDefine(location.getLocation(), context, memory, args);
|
||||||
|
|
||||||
if (functionType != TFunctionType.RETURN_FUNCTION)
|
if (functionType != TFunctionType.RETURN_FUNCTION)
|
||||||
throw EaterExceptionLocated.unlocated("Illegal call here. Is there a return directive in your function?",
|
throw new EaterException("Illegal call here. Is there a return directive in your function?", location);
|
||||||
location);
|
|
||||||
|
|
||||||
final TMemory copy = getNewMemory(memory, args, named);
|
final TMemory copy = getNewMemory(memory, args, named);
|
||||||
final TValue result = context.executeLines(copy, body, TFunctionType.RETURN_FUNCTION, true);
|
final TValue result = context.executeLines(copy, body, TFunctionType.RETURN_FUNCTION, true);
|
||||||
if (result == null)
|
if (result == null)
|
||||||
throw EaterExceptionLocated.unlocated("No return directive found in your function", location);
|
throw new EaterException("No return directive found in your function", location);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TValue executeReturnLegacyDefine(LineLocation location, TContext context, TMemory memory, List<TValue> args)
|
private TValue executeReturnLegacyDefine(LineLocation location, TContext context, TMemory memory, List<TValue> args)
|
||||||
throws EaterExceptionLocated {
|
throws EaterException {
|
||||||
if (legacyDefinition == null)
|
if (legacyDefinition == null)
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public interface TMemory {
|
|||||||
public TValue getVariable(String varname);
|
public TValue getVariable(String varname);
|
||||||
|
|
||||||
public void putVariable(String varname, TValue value, TVariableScope scope, StringLocated location)
|
public void putVariable(String varname, TValue value, TVariableScope scope, StringLocated location)
|
||||||
throws EaterExceptionLocated;
|
throws EaterException;
|
||||||
|
|
||||||
public void removeVariable(String varname);
|
public void removeVariable(String varname);
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ public interface TMemory {
|
|||||||
|
|
||||||
public ExecutionContextIf peekIf();
|
public ExecutionContextIf peekIf();
|
||||||
|
|
||||||
public boolean areAllIfOk(TContext context, TMemory memory) throws EaterExceptionLocated;
|
public boolean areAllIfOk(TContext context, TMemory memory) throws EaterException;
|
||||||
|
|
||||||
public void addIf(ExecutionContextIf context);
|
public void addIf(ExecutionContextIf context);
|
||||||
|
|
||||||
|
@ -73,10 +73,10 @@ public class TMemoryGlobal extends ExecutionContexts implements TMemory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putVariable(String varname, TValue value, TVariableScope scope, StringLocated location)
|
public void putVariable(String varname, TValue value, TVariableScope scope, StringLocated location)
|
||||||
throws EaterExceptionLocated {
|
throws EaterException {
|
||||||
Log.info("[MemGlobal] Setting " + varname);
|
Log.info("[MemGlobal] Setting " + varname);
|
||||||
if (scope == TVariableScope.LOCAL)
|
if (scope == TVariableScope.LOCAL)
|
||||||
throw EaterExceptionLocated.unlocated("Cannot use local variable here", location);
|
throw new EaterException("Cannot use local variable here", location);
|
||||||
|
|
||||||
this.globalVariables.put(varname, value);
|
this.globalVariables.put(varname, value);
|
||||||
this.variables.add(varname);
|
this.variables.add(varname);
|
||||||
|
@ -79,7 +79,7 @@ public class TMemoryLocal extends ExecutionContexts implements TMemory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putVariable(String varname, TValue value, TVariableScope scope, StringLocated location)
|
public void putVariable(String varname, TValue value, TVariableScope scope, StringLocated location)
|
||||||
throws EaterExceptionLocated {
|
throws EaterException {
|
||||||
if (scope == TVariableScope.GLOBAL) {
|
if (scope == TVariableScope.GLOBAL) {
|
||||||
memoryGlobal.putVariable(varname, value, scope, location);
|
memoryGlobal.putVariable(varname, value, scope, location);
|
||||||
return;
|
return;
|
||||||
|
@ -57,7 +57,7 @@ public class TimLoader {
|
|||||||
this.context = new TContext(importedFiles, defines, charset, definitionsContainer);
|
this.context = new TContext(importedFiles, defines, charset, definitionsContainer);
|
||||||
try {
|
try {
|
||||||
defines.copyTo(global, location);
|
defines.copyTo(global, location);
|
||||||
} catch (EaterExceptionLocated e) {
|
} catch (EaterException e) {
|
||||||
Logme.error(e);
|
Logme.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ public class TimLoader {
|
|||||||
// CodeIteratorImpl.indentNow(list);
|
// CodeIteratorImpl.indentNow(list);
|
||||||
try {
|
try {
|
||||||
context.executeLines(global, list, null, false);
|
context.executeLines(global, list, null, false);
|
||||||
} catch (EaterExceptionLocated e) {
|
} catch (EaterException e) {
|
||||||
context.getResultList().add(e.getLocation().withErrorPreprocessor(e.getMessage()));
|
context.getResultList().add(e.getLocation().withErrorPreprocessor(e.getMessage()));
|
||||||
changeLastLine(context.getDebug(), e.getMessage());
|
changeLastLine(context.getDebug(), e.getMessage());
|
||||||
this.preprocessorError = true;
|
this.preprocessorError = true;
|
||||||
|
@ -53,7 +53,7 @@ public class VariableManager {
|
|||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int replaceVariables(String str, int i, StringBuilder result) throws EaterExceptionLocated {
|
public int replaceVariables(String str, int i, StringBuilder result) throws EaterException {
|
||||||
final String presentVariable = getVarnameAt(str, i);
|
final String presentVariable = getVarnameAt(str, i);
|
||||||
if (result.toString().endsWith("##"))
|
if (result.toString().endsWith("##"))
|
||||||
result.setLength(result.length() - 2);
|
result.setLength(result.length() - 2);
|
||||||
@ -80,7 +80,7 @@ public class VariableManager {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int replaceJson(JsonValue jsonValue, String str, int i, StringBuilder result) throws EaterExceptionLocated {
|
private int replaceJson(JsonValue jsonValue, String str, int i, StringBuilder result) throws EaterException {
|
||||||
while (i < str.length()) {
|
while (i < str.length()) {
|
||||||
final char n = str.charAt(i);
|
final char n = str.charAt(i);
|
||||||
if (n == '.') {
|
if (n == '.') {
|
||||||
@ -118,11 +118,11 @@ public class VariableManager {
|
|||||||
} else if (jsonValue instanceof JsonObject) {
|
} else if (jsonValue instanceof JsonObject) {
|
||||||
jsonValue = ((JsonObject) jsonValue).get(nbString);
|
jsonValue = ((JsonObject) jsonValue).get(nbString);
|
||||||
} else {
|
} else {
|
||||||
throw EaterExceptionLocated.unlocated("Major parsing error", location);
|
throw new EaterException("Major parsing error", location);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jsonValue == null)
|
if (jsonValue == null)
|
||||||
throw EaterExceptionLocated.unlocated("Data parsing error", location);
|
throw new EaterException("Data parsing error", location);
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
} else {
|
} else {
|
||||||
|
@ -34,13 +34,13 @@
|
|||||||
*/
|
*/
|
||||||
package net.sourceforge.plantuml.tim.expression;
|
package net.sourceforge.plantuml.tim.expression;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TFunction;
|
import net.sourceforge.plantuml.tim.TFunction;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
|
|
||||||
public interface Knowledge {
|
public interface Knowledge {
|
||||||
|
|
||||||
public TValue getVariable(String name) throws EaterExceptionLocated;
|
public TValue getVariable(String name) throws EaterException;
|
||||||
|
|
||||||
public TFunction getFunction(TFunctionSignature signature);
|
public TFunction getFunction(TFunctionSignature signature);
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ import java.util.Deque;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunction;
|
import net.sourceforge.plantuml.tim.TFunction;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
@ -53,7 +53,7 @@ public class ReversePolishInterpretor {
|
|||||||
private final boolean trace = false;
|
private final boolean trace = false;
|
||||||
|
|
||||||
public ReversePolishInterpretor(StringLocated location, TokenStack queue, Knowledge knowledge, TMemory memory,
|
public ReversePolishInterpretor(StringLocated location, TokenStack queue, Knowledge knowledge, TMemory memory,
|
||||||
TContext context) throws EaterExceptionLocated {
|
TContext context) throws EaterException {
|
||||||
|
|
||||||
final Deque<TValue> stack = new ArrayDeque<>();
|
final Deque<TValue> stack = new ArrayDeque<>();
|
||||||
if (trace)
|
if (trace)
|
||||||
@ -73,7 +73,7 @@ public class ReversePolishInterpretor {
|
|||||||
final TValue v1 = stack.removeFirst();
|
final TValue v1 = stack.removeFirst();
|
||||||
final TokenOperator op = token.getTokenOperator();
|
final TokenOperator op = token.getTokenOperator();
|
||||||
if (op == null)
|
if (op == null)
|
||||||
throw EaterExceptionLocated.unlocated("bad op", location);
|
throw new EaterException("bad op", location);
|
||||||
|
|
||||||
final TValue tmp = op.operate(v1, v2);
|
final TValue tmp = op.operate(v1, v2);
|
||||||
stack.addFirst(tmp);
|
stack.addFirst(tmp);
|
||||||
@ -81,7 +81,7 @@ public class ReversePolishInterpretor {
|
|||||||
final int nb = Integer.parseInt(token.getSurface());
|
final int nb = Integer.parseInt(token.getSurface());
|
||||||
final Token token2 = it.nextToken();
|
final Token token2 = it.nextToken();
|
||||||
if (token2.getTokenType() != TokenType.FUNCTION_NAME)
|
if (token2.getTokenType() != TokenType.FUNCTION_NAME)
|
||||||
throw EaterExceptionLocated.unlocated("rpn43", location);
|
throw new EaterException("rpn43", location);
|
||||||
|
|
||||||
if (trace)
|
if (trace)
|
||||||
System.err.println("token2=" + token2);
|
System.err.println("token2=" + token2);
|
||||||
@ -89,11 +89,10 @@ public class ReversePolishInterpretor {
|
|||||||
if (trace)
|
if (trace)
|
||||||
System.err.println("function=" + function);
|
System.err.println("function=" + function);
|
||||||
if (function == null)
|
if (function == null)
|
||||||
throw EaterExceptionLocated.unlocated("Unknown built-in function " + token2.getSurface(), location);
|
throw new EaterException("Unknown built-in function " + token2.getSurface(), location);
|
||||||
|
|
||||||
if (function.canCover(nb, Collections.<String>emptySet()) == false)
|
if (function.canCover(nb, Collections.<String>emptySet()) == false)
|
||||||
throw EaterExceptionLocated.unlocated(
|
throw new EaterException("Bad number of arguments for " + function.getSignature().getFunctionName(), location);
|
||||||
"Bad number of arguments for " + function.getSignature().getFunctionName(), location);
|
|
||||||
|
|
||||||
final List<TValue> args = new ArrayList<>();
|
final List<TValue> args = new ArrayList<>();
|
||||||
for (int i = 0; i < nb; i++)
|
for (int i = 0; i < nb; i++)
|
||||||
@ -102,7 +101,7 @@ public class ReversePolishInterpretor {
|
|||||||
if (trace)
|
if (trace)
|
||||||
System.err.println("args=" + args);
|
System.err.println("args=" + args);
|
||||||
if (location == null)
|
if (location == null)
|
||||||
throw EaterExceptionLocated.unlocated("rpn44", location);
|
throw new EaterException("rpn44", location);
|
||||||
|
|
||||||
final TValue r = function.executeReturnFunction(context, memory, location, args,
|
final TValue r = function.executeReturnFunction(context, memory, location, args,
|
||||||
Collections.<String, TValue>emptyMap());
|
Collections.<String, TValue>emptyMap());
|
||||||
@ -110,7 +109,7 @@ public class ReversePolishInterpretor {
|
|||||||
System.err.println("r=" + r);
|
System.err.println("r=" + r);
|
||||||
stack.addFirst(r);
|
stack.addFirst(r);
|
||||||
} else {
|
} else {
|
||||||
throw EaterExceptionLocated.unlocated("rpn41", location);
|
throw new EaterException("rpn41", location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = stack.removeFirst();
|
result = stack.removeFirst();
|
||||||
|
@ -38,7 +38,7 @@ import java.util.ArrayDeque;
|
|||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
|
|
||||||
// https://en.wikipedia.org/wiki/Shunting-yard_algorithm
|
// https://en.wikipedia.org/wiki/Shunting-yard_algorithm
|
||||||
// https://en.cppreference.com/w/c/language/operator_precedence
|
// https://en.cppreference.com/w/c/language/operator_precedence
|
||||||
@ -58,7 +58,7 @@ public class ShuntingYard {
|
|||||||
System.err.println("");
|
System.err.println("");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShuntingYard(TokenIterator it, Knowledge knowledge, StringLocated location) throws EaterExceptionLocated {
|
public ShuntingYard(TokenIterator it, Knowledge knowledge, StringLocated location) throws EaterException {
|
||||||
|
|
||||||
while (it.hasMoreTokens()) {
|
while (it.hasMoreTokens()) {
|
||||||
final Token token = it.nextToken();
|
final Token token = it.nextToken();
|
||||||
@ -74,7 +74,7 @@ public class ShuntingYard {
|
|||||||
final TValue variable = knowledge.getVariable(name);
|
final TValue variable = knowledge.getVariable(name);
|
||||||
if (variable == null) {
|
if (variable == null) {
|
||||||
if (isVariableName(name) == false)
|
if (isVariableName(name) == false)
|
||||||
throw EaterExceptionLocated.unlocated("Parsing syntax error about " + name, location);
|
throw new EaterException("Parsing syntax error about " + name, location);
|
||||||
|
|
||||||
ouputQueue.add(new Token(name, TokenType.QUOTED_STRING, null));
|
ouputQueue.add(new Token(name, TokenType.QUOTED_STRING, null));
|
||||||
} else {
|
} else {
|
||||||
|
@ -44,7 +44,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.Eater;
|
import net.sourceforge.plantuml.tim.Eater;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ public class TokenStack {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public TokenStack eatUntilCloseParenthesisOrComma(Eater eater) throws EaterExceptionLocated {
|
static public TokenStack eatUntilCloseParenthesisOrComma(Eater eater) throws EaterException {
|
||||||
final TokenStack result = new TokenStack();
|
final TokenStack result = new TokenStack();
|
||||||
int level = 0;
|
int level = 0;
|
||||||
Token lastToken = null;
|
Token lastToken = null;
|
||||||
@ -94,7 +94,7 @@ public class TokenStack {
|
|||||||
eater.skipSpaces();
|
eater.skipSpaces();
|
||||||
final char ch = eater.peekChar();
|
final char ch = eater.peekChar();
|
||||||
if (ch == 0)
|
if (ch == 0)
|
||||||
throw EaterExceptionLocated.unlocated("until001", eater.getStringLocated());
|
throw new EaterException("until001", eater.getStringLocated());
|
||||||
|
|
||||||
if (level == 0 && (ch == ',' || ch == ')'))
|
if (level == 0 && (ch == ',' || ch == ')'))
|
||||||
return result;
|
return result;
|
||||||
@ -113,12 +113,12 @@ public class TokenStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static public void eatUntilCloseParenthesisOrComma(TokenIterator it, StringLocated location)
|
static public void eatUntilCloseParenthesisOrComma(TokenIterator it, StringLocated location)
|
||||||
throws EaterExceptionLocated {
|
throws EaterException {
|
||||||
int level = 0;
|
int level = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
final Token ch = it.peekToken();
|
final Token ch = it.peekToken();
|
||||||
if (ch == null)
|
if (ch == null)
|
||||||
throw EaterExceptionLocated.unlocated("until002", location);
|
throw new EaterException("until002", location);
|
||||||
|
|
||||||
final TokenType typech = ch.getTokenType();
|
final TokenType typech = ch.getTokenType();
|
||||||
if (level == 0 && (typech == TokenType.COMMA || typech == TokenType.CLOSE_PAREN_MATH)
|
if (level == 0 && (typech == TokenType.COMMA || typech == TokenType.CLOSE_PAREN_MATH)
|
||||||
@ -135,7 +135,7 @@ public class TokenStack {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int countFunctionArg(TokenIterator it, StringLocated location) throws EaterExceptionLocated {
|
private int countFunctionArg(TokenIterator it, StringLocated location) throws EaterException {
|
||||||
// return 42;
|
// return 42;
|
||||||
final TokenType type1 = it.peekToken().getTokenType();
|
final TokenType type1 = it.peekToken().getTokenType();
|
||||||
if (type1 == TokenType.CLOSE_PAREN_MATH || type1 == TokenType.CLOSE_PAREN_FUNC)
|
if (type1 == TokenType.CLOSE_PAREN_MATH || type1 == TokenType.CLOSE_PAREN_FUNC)
|
||||||
@ -151,13 +151,13 @@ public class TokenStack {
|
|||||||
else if (type == TokenType.COMMA)
|
else if (type == TokenType.COMMA)
|
||||||
result++;
|
result++;
|
||||||
else
|
else
|
||||||
throw EaterExceptionLocated.unlocated("count13", location);
|
throw new EaterException("count13", location);
|
||||||
|
|
||||||
}
|
}
|
||||||
throw EaterExceptionLocated.unlocated("count12", location);
|
throw new EaterException("count12", location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void guessFunctions(StringLocated location) throws EaterExceptionLocated {
|
public void guessFunctions(StringLocated location) throws EaterException {
|
||||||
final Deque<Integer> open = new ArrayDeque<>();
|
final Deque<Integer> open = new ArrayDeque<>();
|
||||||
final Map<Integer, Integer> parens = new HashMap<Integer, Integer>();
|
final Map<Integer, Integer> parens = new HashMap<Integer, Integer>();
|
||||||
for (int i = 0; i < tokens.size(); i++) {
|
for (int i = 0; i < tokens.size(); i++) {
|
||||||
@ -210,7 +210,7 @@ public class TokenStack {
|
|||||||
return new InternalIterator();
|
return new InternalIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TValue getResult(StringLocated location, TContext context, TMemory memory) throws EaterExceptionLocated {
|
public TValue getResult(StringLocated location, TContext context, TMemory memory) throws EaterException {
|
||||||
final Knowledge knowledge = context.asKnowledge(memory, location.getLocation());
|
final Knowledge knowledge = context.asKnowledge(memory, location.getLocation());
|
||||||
final TokenStack tmp = withoutSpace();
|
final TokenStack tmp = withoutSpace();
|
||||||
tmp.guessFunctions(location);
|
tmp.guessFunctions(location);
|
||||||
|
@ -36,7 +36,7 @@ package net.sourceforge.plantuml.tim.expression;
|
|||||||
|
|
||||||
import net.sourceforge.plantuml.text.TLineType;
|
import net.sourceforge.plantuml.text.TLineType;
|
||||||
import net.sourceforge.plantuml.tim.Eater;
|
import net.sourceforge.plantuml.tim.Eater;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
|
|
||||||
public enum TokenType {
|
public enum TokenType {
|
||||||
// ::remove folder when __HAXE__
|
// ::remove folder when __HAXE__
|
||||||
@ -78,7 +78,7 @@ public enum TokenType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final static public Token eatOneToken(Token lastToken, Eater eater, boolean manageColon)
|
final static public Token eatOneToken(Token lastToken, Eater eater, boolean manageColon)
|
||||||
throws EaterExceptionLocated {
|
throws EaterException {
|
||||||
char ch = eater.peekChar();
|
char ch = eater.peekChar();
|
||||||
if (ch == 0)
|
if (ch == 0)
|
||||||
return null;
|
return null;
|
||||||
@ -122,7 +122,7 @@ public enum TokenType {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static private String eatAndGetTokenPlainText(Eater eater) throws EaterExceptionLocated {
|
static private String eatAndGetTokenPlainText(Eater eater) throws EaterException {
|
||||||
final StringBuilder result = new StringBuilder();
|
final StringBuilder result = new StringBuilder();
|
||||||
while (true) {
|
while (true) {
|
||||||
final char ch = eater.peekChar();
|
final char ch = eater.peekChar();
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
package net.sourceforge.plantuml.tim.iterator;
|
package net.sourceforge.plantuml.tim.iterator;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
|
|
||||||
public abstract class AbstractCodeIterator implements CodeIterator {
|
public abstract class AbstractCodeIterator implements CodeIterator {
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ public abstract class AbstractCodeIterator implements CodeIterator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void next() throws EaterExceptionLocated {
|
public void next() throws EaterException {
|
||||||
source.next();
|
source.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ public abstract class AbstractCodeIterator implements CodeIterator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
final public void jumpToCodePosition(CodePosition newPosition, StringLocated location)
|
final public void jumpToCodePosition(CodePosition newPosition, StringLocated location)
|
||||||
throws EaterExceptionLocated {
|
throws EaterException {
|
||||||
source.jumpToCodePosition(newPosition, location);
|
source.jumpToCodePosition(newPosition, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,17 +35,17 @@
|
|||||||
package net.sourceforge.plantuml.tim.iterator;
|
package net.sourceforge.plantuml.tim.iterator;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
|
|
||||||
public interface CodeIterator {
|
public interface CodeIterator {
|
||||||
// ::remove folder when __HAXE__
|
// ::remove folder when __HAXE__
|
||||||
|
|
||||||
public StringLocated peek() throws EaterExceptionLocated;
|
public StringLocated peek() throws EaterException;
|
||||||
|
|
||||||
public void next() throws EaterExceptionLocated;
|
public void next() throws EaterException;
|
||||||
|
|
||||||
public CodePosition getCodePosition();
|
public CodePosition getCodePosition();
|
||||||
|
|
||||||
public void jumpToCodePosition(CodePosition newPosition, StringLocated location) throws EaterExceptionLocated;
|
public void jumpToCodePosition(CodePosition newPosition, StringLocated location) throws EaterException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ import net.sourceforge.plantuml.json.ParseException;
|
|||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.text.TLineType;
|
import net.sourceforge.plantuml.text.TLineType;
|
||||||
import net.sourceforge.plantuml.tim.EaterAffectation;
|
import net.sourceforge.plantuml.tim.EaterAffectation;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ public class CodeIteratorAffectation extends AbstractCodeIterator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StringLocated peek() throws EaterExceptionLocated {
|
public StringLocated peek() throws EaterException {
|
||||||
while (true) {
|
while (true) {
|
||||||
final StringLocated result = source.peek();
|
final StringLocated result = source.peek();
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
@ -74,7 +74,7 @@ public class CodeIteratorAffectation extends AbstractCodeIterator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doAffectation(StringLocated result) throws EaterExceptionLocated {
|
private void doAffectation(StringLocated result) throws EaterException {
|
||||||
int lastLocation = -1;
|
int lastLocation = -1;
|
||||||
for (int i = 0; i < 9999; i++)
|
for (int i = 0; i < 9999; i++)
|
||||||
try {
|
try {
|
||||||
@ -82,7 +82,7 @@ public class CodeIteratorAffectation extends AbstractCodeIterator {
|
|||||||
return;
|
return;
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
if (e.getColumn() <= lastLocation)
|
if (e.getColumn() <= lastLocation)
|
||||||
throw EaterExceptionLocated.located("Error in JSON format", result);
|
throw new EaterException("Error in JSON format", result);
|
||||||
|
|
||||||
lastLocation = e.getColumn();
|
lastLocation = e.getColumn();
|
||||||
next();
|
next();
|
||||||
@ -92,7 +92,7 @@ public class CodeIteratorAffectation extends AbstractCodeIterator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void executeAffectation(TContext context, TMemory memory, StringLocated s)
|
private void executeAffectation(TContext context, TMemory memory, StringLocated s)
|
||||||
throws EaterExceptionLocated {
|
throws EaterException {
|
||||||
new EaterAffectation(s).analyze(context, memory);
|
new EaterAffectation(s).analyze(context, memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ import java.util.List;
|
|||||||
import net.sourceforge.plantuml.json.JsonValue;
|
import net.sourceforge.plantuml.json.JsonValue;
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.text.TLineType;
|
import net.sourceforge.plantuml.text.TLineType;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.EaterForeach;
|
import net.sourceforge.plantuml.tim.EaterForeach;
|
||||||
import net.sourceforge.plantuml.tim.ExecutionContextForeach;
|
import net.sourceforge.plantuml.tim.ExecutionContextForeach;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
@ -60,7 +60,7 @@ public class CodeIteratorForeach extends AbstractCodeIterator {
|
|||||||
this.logs = logs;
|
this.logs = logs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringLocated peek() throws EaterExceptionLocated {
|
public StringLocated peek() throws EaterException {
|
||||||
int level = 0;
|
int level = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
final StringLocated result = source.peek();
|
final StringLocated result = source.peek();
|
||||||
@ -90,7 +90,7 @@ public class CodeIteratorForeach extends AbstractCodeIterator {
|
|||||||
} else if (result.getType() == TLineType.ENDFOREACH) {
|
} else if (result.getType() == TLineType.ENDFOREACH) {
|
||||||
logs.add(result);
|
logs.add(result);
|
||||||
if (foreach == null)
|
if (foreach == null)
|
||||||
throw EaterExceptionLocated.located("No foreach related to this endforeach", result);
|
throw new EaterException("No foreach related to this endforeach", result);
|
||||||
|
|
||||||
foreach.inc();
|
foreach.inc();
|
||||||
if (foreach.isSkipMe()) {
|
if (foreach.isSkipMe()) {
|
||||||
@ -107,7 +107,7 @@ public class CodeIteratorForeach extends AbstractCodeIterator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeForeach(TMemory memory, StringLocated s) throws EaterExceptionLocated {
|
private void executeForeach(TMemory memory, StringLocated s) throws EaterException {
|
||||||
final EaterForeach condition = new EaterForeach(s);
|
final EaterForeach condition = new EaterForeach(s);
|
||||||
condition.analyze(context, memory);
|
condition.analyze(context, memory);
|
||||||
final ExecutionContextForeach foreach = ExecutionContextForeach.fromValue(condition.getVarname(),
|
final ExecutionContextForeach foreach = ExecutionContextForeach.fromValue(condition.getVarname(),
|
||||||
@ -121,7 +121,7 @@ public class CodeIteratorForeach extends AbstractCodeIterator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setLoopVariable(TMemory memory, ExecutionContextForeach foreach, StringLocated position)
|
private void setLoopVariable(TMemory memory, ExecutionContextForeach foreach, StringLocated position)
|
||||||
throws EaterExceptionLocated {
|
throws EaterException {
|
||||||
final JsonValue first = foreach.getJsonArray().get(foreach.currentIndex());
|
final JsonValue first = foreach.getJsonArray().get(foreach.currentIndex());
|
||||||
memory.putVariable(foreach.getVarname(), TValue.fromJson(first), TVariableScope.GLOBAL, position);
|
memory.putVariable(foreach.getVarname(), TValue.fromJson(first), TVariableScope.GLOBAL, position);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ import java.util.List;
|
|||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.text.TLineType;
|
import net.sourceforge.plantuml.text.TLineType;
|
||||||
import net.sourceforge.plantuml.tim.EaterElseIf;
|
import net.sourceforge.plantuml.tim.EaterElseIf;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.EaterIf;
|
import net.sourceforge.plantuml.tim.EaterIf;
|
||||||
import net.sourceforge.plantuml.tim.EaterIfdef;
|
import net.sourceforge.plantuml.tim.EaterIfdef;
|
||||||
import net.sourceforge.plantuml.tim.EaterIfndef;
|
import net.sourceforge.plantuml.tim.EaterIfndef;
|
||||||
@ -60,7 +60,7 @@ public class CodeIteratorIf extends AbstractCodeIterator {
|
|||||||
this.logs = logs;
|
this.logs = logs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringLocated peek() throws EaterExceptionLocated {
|
public StringLocated peek() throws EaterException {
|
||||||
while (true) {
|
while (true) {
|
||||||
final StringLocated result = source.peek();
|
final StringLocated result = source.peek();
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
@ -106,17 +106,17 @@ public class CodeIteratorIf extends AbstractCodeIterator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeIf(TContext context, TMemory memory, StringLocated s) throws EaterExceptionLocated {
|
private void executeIf(TContext context, TMemory memory, StringLocated s) throws EaterException {
|
||||||
final EaterIf condition = new EaterIf(s);
|
final EaterIf condition = new EaterIf(s);
|
||||||
condition.analyze(context, memory);
|
condition.analyze(context, memory);
|
||||||
final boolean isTrue = condition.isTrue();
|
final boolean isTrue = condition.isTrue();
|
||||||
memory.addIf(ExecutionContextIf.fromValue(isTrue));
|
memory.addIf(ExecutionContextIf.fromValue(isTrue));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeElseIf(TContext context, TMemory memory, StringLocated s) throws EaterExceptionLocated {
|
private void executeElseIf(TContext context, TMemory memory, StringLocated s) throws EaterException {
|
||||||
final ExecutionContextIf poll = (ExecutionContextIf) memory.peekIf();
|
final ExecutionContextIf poll = (ExecutionContextIf) memory.peekIf();
|
||||||
if (poll == null)
|
if (poll == null)
|
||||||
throw EaterExceptionLocated.located("No if related to this else", s);
|
throw new EaterException("No if related to this else", s);
|
||||||
|
|
||||||
poll.enteringElseIf();
|
poll.enteringElseIf();
|
||||||
if (poll.hasBeenBurn() == false) {
|
if (poll.hasBeenBurn() == false) {
|
||||||
@ -129,32 +129,32 @@ public class CodeIteratorIf extends AbstractCodeIterator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeIfdef(TContext context, TMemory memory, StringLocated s) throws EaterExceptionLocated {
|
private void executeIfdef(TContext context, TMemory memory, StringLocated s) throws EaterException {
|
||||||
final EaterIfdef condition = new EaterIfdef(s);
|
final EaterIfdef condition = new EaterIfdef(s);
|
||||||
condition.analyze(context, memory);
|
condition.analyze(context, memory);
|
||||||
final boolean isTrue = condition.isTrue(context, memory);
|
final boolean isTrue = condition.isTrue(context, memory);
|
||||||
memory.addIf(ExecutionContextIf.fromValue(isTrue));
|
memory.addIf(ExecutionContextIf.fromValue(isTrue));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeIfndef(TContext context, TMemory memory, StringLocated s) throws EaterExceptionLocated {
|
private void executeIfndef(TContext context, TMemory memory, StringLocated s) throws EaterException {
|
||||||
final EaterIfndef condition = new EaterIfndef(s);
|
final EaterIfndef condition = new EaterIfndef(s);
|
||||||
condition.analyze(context, memory);
|
condition.analyze(context, memory);
|
||||||
final boolean isTrue = condition.isTrue(context, memory);
|
final boolean isTrue = condition.isTrue(context, memory);
|
||||||
memory.addIf(ExecutionContextIf.fromValue(isTrue));
|
memory.addIf(ExecutionContextIf.fromValue(isTrue));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeElse(TContext context, TMemory memory, StringLocated s) throws EaterExceptionLocated {
|
private void executeElse(TContext context, TMemory memory, StringLocated s) throws EaterException {
|
||||||
final ExecutionContextIf poll = (ExecutionContextIf) memory.peekIf();
|
final ExecutionContextIf poll = (ExecutionContextIf) memory.peekIf();
|
||||||
if (poll == null)
|
if (poll == null)
|
||||||
throw EaterExceptionLocated.located("No if related to this else", s);
|
throw new EaterException("No if related to this else", s);
|
||||||
|
|
||||||
poll.nowInElse();
|
poll.nowInElse();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeEndif(TContext context, TMemory memory, StringLocated s) throws EaterExceptionLocated {
|
private void executeEndif(TContext context, TMemory memory, StringLocated s) throws EaterException {
|
||||||
final ExecutionContextIf poll = (ExecutionContextIf) memory.pollIf();
|
final ExecutionContextIf poll = (ExecutionContextIf) memory.pollIf();
|
||||||
if (poll == null)
|
if (poll == null)
|
||||||
throw EaterExceptionLocated.located("No if related to this endif", s);
|
throw new EaterException("No if related to this endif", s);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ package net.sourceforge.plantuml.tim.iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
|
|
||||||
public class CodeIteratorImpl implements CodeIterator {
|
public class CodeIteratorImpl implements CodeIterator {
|
||||||
|
|
||||||
@ -89,10 +89,10 @@ public class CodeIteratorImpl implements CodeIterator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void jumpToCodePosition(CodePosition newPosition, StringLocated location) throws EaterExceptionLocated {
|
public void jumpToCodePosition(CodePosition newPosition, StringLocated location) throws EaterException {
|
||||||
this.countJump++;
|
this.countJump++;
|
||||||
if (this.countJump > 999)
|
if (this.countJump > 999)
|
||||||
throw EaterExceptionLocated.unlocated("Infinite loop?", location);
|
throw new EaterException("Infinite loop?", location);
|
||||||
|
|
||||||
final Position pos = (Position) newPosition;
|
final Position pos = (Position) newPosition;
|
||||||
this.current = pos.pos;
|
this.current = pos.pos;
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
package net.sourceforge.plantuml.tim.iterator;
|
package net.sourceforge.plantuml.tim.iterator;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
|
|
||||||
public class CodeIteratorInnerComment extends AbstractCodeIterator {
|
public class CodeIteratorInnerComment extends AbstractCodeIterator {
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ public class CodeIteratorInnerComment extends AbstractCodeIterator {
|
|||||||
super(source);
|
super(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringLocated peek() throws EaterExceptionLocated {
|
public StringLocated peek() throws EaterException {
|
||||||
final StringLocated result = source.peek();
|
final StringLocated result = source.peek();
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -38,7 +38,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.text.TLineType;
|
import net.sourceforge.plantuml.text.TLineType;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.FunctionsSet;
|
import net.sourceforge.plantuml.tim.FunctionsSet;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -60,7 +60,7 @@ public class CodeIteratorLegacyDefine extends AbstractCodeIterator {
|
|||||||
this.memory = memory;
|
this.memory = memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringLocated peek() throws EaterExceptionLocated {
|
public StringLocated peek() throws EaterException {
|
||||||
while (true) {
|
while (true) {
|
||||||
final StringLocated result = source.peek();
|
final StringLocated result = source.peek();
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
|
@ -38,7 +38,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.text.TLineType;
|
import net.sourceforge.plantuml.text.TLineType;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
|
|
||||||
public class CodeIteratorLongComment extends AbstractCodeIterator {
|
public class CodeIteratorLongComment extends AbstractCodeIterator {
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public class CodeIteratorLongComment extends AbstractCodeIterator {
|
|||||||
this.logs = logs;
|
this.logs = logs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringLocated peek() throws EaterExceptionLocated {
|
public StringLocated peek() throws EaterException {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (source.peek() == null) {
|
if (source.peek() == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -38,7 +38,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.text.TLineType;
|
import net.sourceforge.plantuml.text.TLineType;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.FunctionsSet;
|
import net.sourceforge.plantuml.tim.FunctionsSet;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionType;
|
import net.sourceforge.plantuml.tim.TFunctionType;
|
||||||
@ -61,7 +61,7 @@ public class CodeIteratorProcedure extends AbstractCodeIterator {
|
|||||||
this.memory = memory;
|
this.memory = memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringLocated peek() throws EaterExceptionLocated {
|
public StringLocated peek() throws EaterException {
|
||||||
while (true) {
|
while (true) {
|
||||||
final StringLocated result = source.peek();
|
final StringLocated result = source.peek();
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
|
@ -38,7 +38,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.text.TLineType;
|
import net.sourceforge.plantuml.text.TLineType;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.FunctionsSet;
|
import net.sourceforge.plantuml.tim.FunctionsSet;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionType;
|
import net.sourceforge.plantuml.tim.TFunctionType;
|
||||||
@ -61,7 +61,7 @@ public class CodeIteratorReturnFunction extends AbstractCodeIterator {
|
|||||||
this.memory = memory;
|
this.memory = memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringLocated peek() throws EaterExceptionLocated {
|
public StringLocated peek() throws EaterException {
|
||||||
while (true) {
|
while (true) {
|
||||||
final StringLocated result = source.peek();
|
final StringLocated result = source.peek();
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
@ -73,9 +73,7 @@ public class CodeIteratorReturnFunction extends AbstractCodeIterator {
|
|||||||
logs.add(result);
|
logs.add(result);
|
||||||
if (result.getType() == TLineType.END_FUNCTION) {
|
if (result.getType() == TLineType.END_FUNCTION) {
|
||||||
if (functionsSet.pendingFunction().doesContainReturn() == false) {
|
if (functionsSet.pendingFunction().doesContainReturn() == false) {
|
||||||
throw EaterExceptionLocated.located(
|
throw new EaterException("This function does not have any !return directive. Declare it as a procedure instead ?", result);
|
||||||
"This function does not have any !return directive. Declare it as a procedure instead ?",
|
|
||||||
result);
|
|
||||||
}
|
}
|
||||||
functionsSet.executeEndfunction();
|
functionsSet.executeEndfunction();
|
||||||
} else {
|
} else {
|
||||||
|
@ -38,7 +38,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.text.TLineType;
|
import net.sourceforge.plantuml.text.TLineType;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
|
|
||||||
public class CodeIteratorShortComment extends AbstractCodeIterator {
|
public class CodeIteratorShortComment extends AbstractCodeIterator {
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public class CodeIteratorShortComment extends AbstractCodeIterator {
|
|||||||
this.logs = logs;
|
this.logs = logs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringLocated peek() throws EaterExceptionLocated {
|
public StringLocated peek() throws EaterException {
|
||||||
while (true) {
|
while (true) {
|
||||||
final StringLocated result = source.peek();
|
final StringLocated result = source.peek();
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
|
@ -40,7 +40,7 @@ import java.util.Map;
|
|||||||
import net.sourceforge.plantuml.preproc.Sub;
|
import net.sourceforge.plantuml.preproc.Sub;
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.text.TLineType;
|
import net.sourceforge.plantuml.text.TLineType;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.EaterStartsub;
|
import net.sourceforge.plantuml.tim.EaterStartsub;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -65,7 +65,7 @@ public class CodeIteratorSub extends AbstractCodeIterator {
|
|||||||
return Collections.unmodifiableMap(subs);
|
return Collections.unmodifiableMap(subs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringLocated peek() throws EaterExceptionLocated {
|
public StringLocated peek() throws EaterException {
|
||||||
if (readingInProgress != null)
|
if (readingInProgress != null)
|
||||||
return readingInProgress.peek();
|
return readingInProgress.peek();
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ public class CodeIteratorSub extends AbstractCodeIterator {
|
|||||||
StringLocated s = null;
|
StringLocated s = null;
|
||||||
while ((s = source.peek()) != null) {
|
while ((s = source.peek()) != null) {
|
||||||
if (s.getType() == TLineType.STARTSUB) {
|
if (s.getType() == TLineType.STARTSUB) {
|
||||||
throw EaterExceptionLocated.located("Cannot nest sub", result);
|
throw new EaterException("Cannot nest sub", result);
|
||||||
} else if (s.getType() == TLineType.ENDSUB) {
|
} else if (s.getType() == TLineType.ENDSUB) {
|
||||||
source.next();
|
source.next();
|
||||||
readingInProgress = new CodeIteratorImpl(created.lines());
|
readingInProgress = new CodeIteratorImpl(created.lines());
|
||||||
@ -100,7 +100,7 @@ public class CodeIteratorSub extends AbstractCodeIterator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void next() throws EaterExceptionLocated {
|
public void next() throws EaterException {
|
||||||
if (readingInProgress == null) {
|
if (readingInProgress == null) {
|
||||||
source.next();
|
source.next();
|
||||||
return;
|
return;
|
||||||
|
@ -38,7 +38,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.text.TLineType;
|
import net.sourceforge.plantuml.text.TLineType;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.EaterWhile;
|
import net.sourceforge.plantuml.tim.EaterWhile;
|
||||||
import net.sourceforge.plantuml.tim.ExecutionContextWhile;
|
import net.sourceforge.plantuml.tim.ExecutionContextWhile;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
@ -59,7 +59,7 @@ public class CodeIteratorWhile extends AbstractCodeIterator {
|
|||||||
this.logs = logs;
|
this.logs = logs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringLocated peek() throws EaterExceptionLocated {
|
public StringLocated peek() throws EaterException {
|
||||||
int level = 0;
|
int level = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
final StringLocated result = source.peek();
|
final StringLocated result = source.peek();
|
||||||
@ -89,7 +89,7 @@ public class CodeIteratorWhile extends AbstractCodeIterator {
|
|||||||
} else if (result.getType() == TLineType.ENDWHILE) {
|
} else if (result.getType() == TLineType.ENDWHILE) {
|
||||||
logs.add(result);
|
logs.add(result);
|
||||||
if (currentWhile == null)
|
if (currentWhile == null)
|
||||||
throw EaterExceptionLocated.located("No while related to this endwhile", result);
|
throw new EaterException("No while related to this endwhile", result);
|
||||||
|
|
||||||
final TValue value = currentWhile.conditionValue(result, context, memory);
|
final TValue value = currentWhile.conditionValue(result, context, memory);
|
||||||
if (value.toBoolean())
|
if (value.toBoolean())
|
||||||
@ -105,7 +105,7 @@ public class CodeIteratorWhile extends AbstractCodeIterator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeWhile(TMemory memory, StringLocated s) throws EaterExceptionLocated {
|
private void executeWhile(TMemory memory, StringLocated s) throws EaterException {
|
||||||
final EaterWhile condition = new EaterWhile(s);
|
final EaterWhile condition = new EaterWhile(s);
|
||||||
condition.analyze(context, memory);
|
condition.analyze(context, memory);
|
||||||
final TokenStack whileExpression = condition.getWhileExpression();
|
final TokenStack whileExpression = condition.getWhileExpression();
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -58,7 +58,7 @@ public class AlwaysFalse extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
return TValue.fromBoolean(false);
|
return TValue.fromBoolean(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -58,7 +58,7 @@ public class AlwaysTrue extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
return TValue.fromBoolean(true);
|
return TValue.fromBoolean(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunction;
|
import net.sourceforge.plantuml.tim.TFunction;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
@ -59,13 +59,13 @@ public class CallUserFunction extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
final String fname = values.get(0).toString();
|
final String fname = values.get(0).toString();
|
||||||
final List<TValue> args = values.subList(1, values.size());
|
final List<TValue> args = values.subList(1, values.size());
|
||||||
final TFunctionSignature signature = new TFunctionSignature(fname, args.size());
|
final TFunctionSignature signature = new TFunctionSignature(fname, args.size());
|
||||||
final TFunction func = context.getFunctionSmart(signature);
|
final TFunction func = context.getFunctionSmart(signature);
|
||||||
if (func == null)
|
if (func == null)
|
||||||
throw EaterExceptionLocated.unlocated("Cannot find void function " + fname, location);
|
throw new EaterException("Cannot find void function " + fname, location);
|
||||||
|
|
||||||
return func.executeReturnFunction(context, memory, location, args, named);
|
return func.executeReturnFunction(context, memory, location, args, named);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -58,7 +58,7 @@ public class Chr extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
try {
|
try {
|
||||||
final String value = String.valueOf(Character.toChars(values.get(0).toInt()));
|
final String value = String.valueOf(Character.toChars(values.get(0).toInt()));
|
||||||
return TValue.fromString(value);
|
return TValue.fromString(value);
|
||||||
|
@ -42,7 +42,7 @@ import net.sourceforge.plantuml.klimt.color.HColor;
|
|||||||
import net.sourceforge.plantuml.klimt.color.HColorSet;
|
import net.sourceforge.plantuml.klimt.color.HColorSet;
|
||||||
import net.sourceforge.plantuml.klimt.color.NoSuchColorException;
|
import net.sourceforge.plantuml.klimt.color.NoSuchColorException;
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -62,7 +62,7 @@ public class Darken extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
final String colorString = values.get(0).toString();
|
final String colorString = values.get(0).toString();
|
||||||
final int ratio = values.get(1).toInt();
|
final int ratio = values.get(1).toInt();
|
||||||
try {
|
try {
|
||||||
@ -70,7 +70,7 @@ public class Darken extends SimpleReturnFunction {
|
|||||||
color = color.darken(ratio);
|
color = color.darken(ratio);
|
||||||
return TValue.fromString(color.asString());
|
return TValue.fromString(color.asString());
|
||||||
} catch (NoSuchColorException e) {
|
} catch (NoSuchColorException e) {
|
||||||
throw EaterExceptionLocated.located("No such color", location);
|
throw new EaterException("No such color", location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -60,7 +60,7 @@ public class DateFunction extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
if (values.size() == 0)
|
if (values.size() == 0)
|
||||||
return TValue.fromString(new Date().toString());
|
return TValue.fromString(new Date().toString());
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ public class DateFunction extends SimpleReturnFunction {
|
|||||||
try {
|
try {
|
||||||
return TValue.fromString(new SimpleDateFormat(format).format(now));
|
return TValue.fromString(new SimpleDateFormat(format).format(now));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw EaterExceptionLocated.unlocated("Bad date pattern", location);
|
throw new EaterException("Bad date pattern", location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -58,7 +58,7 @@ public class Dec2hex extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
try {
|
try {
|
||||||
return TValue.fromString("" + Integer.toHexString(values.get(0).toInt()));
|
return TValue.fromString("" + Integer.toHexString(values.get(0).toInt()));
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
@ -40,7 +40,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import net.sourceforge.plantuml.preproc.Defines;
|
import net.sourceforge.plantuml.preproc.Defines;
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -65,7 +65,7 @@ public class Dirpath extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return TValue.fromString("");
|
return TValue.fromString("");
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.StringEater;
|
import net.sourceforge.plantuml.tim.StringEater;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
@ -59,7 +59,7 @@ public class Eval extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
final String exp = values.get(0).toString();
|
final String exp = values.get(0).toString();
|
||||||
final StringEater eater = new StringEater(exp);
|
final StringEater eater = new StringEater(exp);
|
||||||
final TValue value = eater.eatExpression(context, memory);
|
final TValue value = eater.eatExpression(context, memory);
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -58,7 +58,7 @@ public class Feature extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
final String arg = values.get(0).toString();
|
final String arg = values.get(0).toString();
|
||||||
if ("style".equalsIgnoreCase(arg))
|
if ("style".equalsIgnoreCase(arg))
|
||||||
return TValue.fromInt(1);
|
return TValue.fromInt(1);
|
||||||
|
@ -40,7 +40,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import net.sourceforge.plantuml.security.SFile;
|
import net.sourceforge.plantuml.security.SFile;
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -59,7 +59,7 @@ public class FileExists extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
// ::comment when __CORE__
|
// ::comment when __CORE__
|
||||||
final String path = values.get(0).toString();
|
final String path = values.get(0).toString();
|
||||||
return TValue.fromBoolean(new SFile(path).exists());
|
return TValue.fromBoolean(new SFile(path).exists());
|
||||||
|
@ -40,7 +40,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import net.sourceforge.plantuml.preproc.Defines;
|
import net.sourceforge.plantuml.preproc.Defines;
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -65,7 +65,7 @@ public class Filename extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return TValue.fromString("");
|
return TValue.fromString("");
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -59,7 +59,7 @@ public class FunctionExists extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
final String name = values.get(0).toString();
|
final String name = values.get(0).toString();
|
||||||
return TValue.fromBoolean(context.doesFunctionExist(name));
|
return TValue.fromBoolean(context.doesFunctionExist(name));
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ import net.sourceforge.plantuml.json.JsonObject;
|
|||||||
import net.sourceforge.plantuml.log.Logme;
|
import net.sourceforge.plantuml.log.Logme;
|
||||||
import net.sourceforge.plantuml.preproc.Stdlib;
|
import net.sourceforge.plantuml.preproc.Stdlib;
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -64,7 +64,7 @@ public class GetAllStdlib extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
|
|
||||||
switch (values.size()) {
|
switch (values.size()) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -99,7 +99,7 @@ public class GetAllStdlib extends SimpleReturnFunction {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
assert false; // Should not append because of canCover()
|
assert false; // Should not append because of canCover()
|
||||||
throw EaterExceptionLocated.located("Error on get_all_stdlib: Too many arguments", location);
|
throw new EaterException("Error on get_all_stdlib: Too many arguments", location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ import net.sourceforge.plantuml.json.JsonArray;
|
|||||||
import net.sourceforge.plantuml.log.Logme;
|
import net.sourceforge.plantuml.log.Logme;
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.theme.ThemeUtils;
|
import net.sourceforge.plantuml.theme.ThemeUtils;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -62,7 +62,7 @@ public class GetAllTheme extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
final JsonArray result = new JsonArray();
|
final JsonArray result = new JsonArray();
|
||||||
try {
|
try {
|
||||||
for (String theme : ThemeUtils.getAllThemeNames()) {
|
for (String theme : ThemeUtils.getAllThemeNames()) {
|
||||||
|
@ -42,7 +42,7 @@ import net.sourceforge.plantuml.json.JsonArray;
|
|||||||
import net.sourceforge.plantuml.json.JsonObject;
|
import net.sourceforge.plantuml.json.JsonObject;
|
||||||
import net.sourceforge.plantuml.json.JsonValue;
|
import net.sourceforge.plantuml.json.JsonValue;
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -61,10 +61,10 @@ public class GetJsonKey extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
final TValue data = values.get(0);
|
final TValue data = values.get(0);
|
||||||
if (data.isJson() == false)
|
if (data.isJson() == false)
|
||||||
throw EaterExceptionLocated.unlocated("Not JSON data", location);
|
throw new EaterException("Not JSON data", location);
|
||||||
|
|
||||||
final JsonValue json = data.toJson();
|
final JsonValue json = data.toJson();
|
||||||
if (json.isObject()) {
|
if (json.isObject()) {
|
||||||
@ -87,7 +87,7 @@ public class GetJsonKey extends SimpleReturnFunction {
|
|||||||
return TValue.fromJson(result);
|
return TValue.fromJson(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw EaterExceptionLocated.unlocated("Bad JSON type", location);
|
throw new EaterException("Bad JSON type", location);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import net.sourceforge.plantuml.json.JsonValue;
|
import net.sourceforge.plantuml.json.JsonValue;
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -59,7 +59,7 @@ public class GetJsonType extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
final TValue data = values.get(0);
|
final TValue data = values.get(0);
|
||||||
if (data.isString())
|
if (data.isString())
|
||||||
return TValue.fromString("string");
|
return TValue.fromString("string");
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -58,7 +58,7 @@ public class GetVariableValue extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
final String name = values.get(0).toString();
|
final String name = values.get(0).toString();
|
||||||
final TValue variable = memory.getVariable(name);
|
final TValue variable = memory.getVariable(name);
|
||||||
if (variable == null)
|
if (variable == null)
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -59,7 +59,7 @@ public class GetVersion extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
return TValue.fromString(Version.versionString());
|
return TValue.fromString(Version.versionString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import net.sourceforge.plantuml.security.SecurityUtils;
|
import net.sourceforge.plantuml.security.SecurityUtils;
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -59,7 +59,7 @@ public class Getenv extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
// ::comment when __CORE__
|
// ::comment when __CORE__
|
||||||
final String value = getenv(values.get(0).toString());
|
final String value = getenv(values.get(0).toString());
|
||||||
if (value == null)
|
if (value == null)
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -58,7 +58,7 @@ public class Hex2dec extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
try {
|
try {
|
||||||
return TValue.fromInt(Integer.parseInt(values.get(0).toString(), 16));
|
return TValue.fromInt(Integer.parseInt(values.get(0).toString(), 16));
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
@ -42,7 +42,7 @@ import java.util.Set;
|
|||||||
import net.sourceforge.plantuml.klimt.color.HColors;
|
import net.sourceforge.plantuml.klimt.color.HColors;
|
||||||
import net.sourceforge.plantuml.klimt.color.HSLColor;
|
import net.sourceforge.plantuml.klimt.color.HSLColor;
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -61,7 +61,7 @@ public class HslColor extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
final int h = values.get(0).toInt();
|
final int h = values.get(0).toInt();
|
||||||
final int s = values.get(1).toInt();
|
final int s = values.get(1).toInt();
|
||||||
final int l = values.get(2).toInt();
|
final int l = values.get(2).toInt();
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -59,7 +59,7 @@ public class IntVal extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
final String s = values.get(0).toString();
|
final String s = values.get(0).toString();
|
||||||
try {
|
try {
|
||||||
return TValue.fromInt(Integer.parseInt(s));
|
return TValue.fromInt(Integer.parseInt(s));
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunction;
|
import net.sourceforge.plantuml.tim.TFunction;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
@ -64,13 +64,13 @@ public class InvokeProcedure implements TFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executeProcedureInternal(TContext context, TMemory memory, StringLocated location, List<TValue> args,
|
public void executeProcedureInternal(TContext context, TMemory memory, StringLocated location, List<TValue> args,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
final String fname = args.get(0).toString();
|
final String fname = args.get(0).toString();
|
||||||
final List<TValue> sublist = args.subList(1, args.size());
|
final List<TValue> sublist = args.subList(1, args.size());
|
||||||
final TFunctionSignature signature = new TFunctionSignature(fname, sublist.size());
|
final TFunctionSignature signature = new TFunctionSignature(fname, sublist.size());
|
||||||
final TFunction func = context.getFunctionSmart(signature);
|
final TFunction func = context.getFunctionSmart(signature);
|
||||||
if (func == null)
|
if (func == null)
|
||||||
throw EaterExceptionLocated.located("Cannot find void function " + fname, location);
|
throw new EaterException("Cannot find void function " + fname, location);
|
||||||
|
|
||||||
func.executeProcedureInternal(context, memory, location, sublist, named);
|
func.executeProcedureInternal(context, memory, location, sublist, named);
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ import net.sourceforge.plantuml.klimt.color.HColor;
|
|||||||
import net.sourceforge.plantuml.klimt.color.HColorSet;
|
import net.sourceforge.plantuml.klimt.color.HColorSet;
|
||||||
import net.sourceforge.plantuml.klimt.color.NoSuchColorException;
|
import net.sourceforge.plantuml.klimt.color.NoSuchColorException;
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -62,13 +62,13 @@ public class IsDark extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
final String colorString = values.get(0).toString();
|
final String colorString = values.get(0).toString();
|
||||||
try {
|
try {
|
||||||
final HColor color = HColorSet.instance().getColorLEGACY(colorString);
|
final HColor color = HColorSet.instance().getColorLEGACY(colorString);
|
||||||
return TValue.fromBoolean(color.isDark());
|
return TValue.fromBoolean(color.isDark());
|
||||||
} catch (NoSuchColorException e) {
|
} catch (NoSuchColorException e) {
|
||||||
throw EaterExceptionLocated.located("No such color", location);
|
throw new EaterException("No such color", location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ import net.sourceforge.plantuml.klimt.color.HColor;
|
|||||||
import net.sourceforge.plantuml.klimt.color.HColorSet;
|
import net.sourceforge.plantuml.klimt.color.HColorSet;
|
||||||
import net.sourceforge.plantuml.klimt.color.NoSuchColorException;
|
import net.sourceforge.plantuml.klimt.color.NoSuchColorException;
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -62,13 +62,13 @@ public class IsLight extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
final String colorString = values.get(0).toString();
|
final String colorString = values.get(0).toString();
|
||||||
try {
|
try {
|
||||||
final HColor color = HColorSet.instance().getColorLEGACY(colorString);
|
final HColor color = HColorSet.instance().getColorLEGACY(colorString);
|
||||||
return TValue.fromBoolean(!color.isDark());
|
return TValue.fromBoolean(!color.isDark());
|
||||||
} catch (NoSuchColorException e) {
|
} catch (NoSuchColorException e) {
|
||||||
throw EaterExceptionLocated.located("No such color", location);
|
throw new EaterException("No such color", location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ import java.util.Set;
|
|||||||
import net.sourceforge.plantuml.json.JsonObject;
|
import net.sourceforge.plantuml.json.JsonObject;
|
||||||
import net.sourceforge.plantuml.json.JsonValue;
|
import net.sourceforge.plantuml.json.JsonValue;
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -60,7 +60,7 @@ public class JsonKeyExists extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
final TValue arg0 = values.get(0);
|
final TValue arg0 = values.get(0);
|
||||||
if (arg0.isJson() == false)
|
if (arg0.isJson() == false)
|
||||||
return TValue.fromBoolean(false);
|
return TValue.fromBoolean(false);
|
||||||
|
@ -42,7 +42,7 @@ import net.sourceforge.plantuml.klimt.color.HColor;
|
|||||||
import net.sourceforge.plantuml.klimt.color.HColorSet;
|
import net.sourceforge.plantuml.klimt.color.HColorSet;
|
||||||
import net.sourceforge.plantuml.klimt.color.NoSuchColorException;
|
import net.sourceforge.plantuml.klimt.color.NoSuchColorException;
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -62,7 +62,7 @@ public class Lighten extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
final String colorString = values.get(0).toString();
|
final String colorString = values.get(0).toString();
|
||||||
final int ratio = values.get(1).toInt();
|
final int ratio = values.get(1).toInt();
|
||||||
try {
|
try {
|
||||||
@ -70,7 +70,7 @@ public class Lighten extends SimpleReturnFunction {
|
|||||||
color = color.lighten(ratio);
|
color = color.lighten(ratio);
|
||||||
return TValue.fromString(color.asString());
|
return TValue.fromString(color.asString());
|
||||||
} catch (NoSuchColorException e) {
|
} catch (NoSuchColorException e) {
|
||||||
throw EaterExceptionLocated.located("No such color", location);
|
throw new EaterException("No such color", location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ import net.sourceforge.plantuml.log.Logme;
|
|||||||
import net.sourceforge.plantuml.security.SFile;
|
import net.sourceforge.plantuml.security.SFile;
|
||||||
import net.sourceforge.plantuml.security.SURL;
|
import net.sourceforge.plantuml.security.SURL;
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -108,7 +108,7 @@ public class LoadJson extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
final String path = values.get(0).toString();
|
final String path = values.get(0).toString();
|
||||||
try {
|
try {
|
||||||
String data = loadStringData(path, getCharset(values));
|
String data = loadStringData(path, getCharset(values));
|
||||||
@ -119,12 +119,10 @@ public class LoadJson extends SimpleReturnFunction {
|
|||||||
return TValue.fromJson(jsonValue);
|
return TValue.fromJson(jsonValue);
|
||||||
} catch (ParseException pe) {
|
} catch (ParseException pe) {
|
||||||
Logme.error(pe);
|
Logme.error(pe);
|
||||||
throw EaterExceptionLocated
|
throw new EaterException("JSON parse issue in source " + path + " on location " + pe.getLocation(), location);
|
||||||
.unlocated("JSON parse issue in source " + path + " on location " + pe.getLocation(), location);
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
Logme.error(e);
|
Logme.error(e);
|
||||||
throw EaterExceptionLocated.unlocated("JSON encoding issue in source " + path + ": " + e.getMessage(),
|
throw new EaterException("JSON encoding issue in source " + path + ": " + e.getMessage(), location);
|
||||||
location);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +162,7 @@ public class LoadJson extends SimpleReturnFunction {
|
|||||||
* @throws EaterException if something went wrong on reading data
|
* @throws EaterException if something went wrong on reading data
|
||||||
*/
|
*/
|
||||||
private String loadStringData(String path, String charset)
|
private String loadStringData(String path, String charset)
|
||||||
throws EaterExceptionLocated, UnsupportedEncodingException {
|
throws EaterException, UnsupportedEncodingException {
|
||||||
|
|
||||||
byte[] byteData = null;
|
byte[] byteData = null;
|
||||||
if (path.startsWith("http://") || path.startsWith("https://")) {
|
if (path.startsWith("http://") || path.startsWith("https://")) {
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -58,7 +58,7 @@ public class LogicalAnd extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
for (TValue v : values)
|
for (TValue v : values)
|
||||||
if (v.toBoolean() == false)
|
if (v.toBoolean() == false)
|
||||||
return TValue.fromBoolean(false);
|
return TValue.fromBoolean(false);
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -58,7 +58,7 @@ public class LogicalNand extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
for (TValue v : values)
|
for (TValue v : values)
|
||||||
if (v.toBoolean() == false)
|
if (v.toBoolean() == false)
|
||||||
return TValue.fromBoolean(!false);
|
return TValue.fromBoolean(!false);
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -58,7 +58,7 @@ public class LogicalNor extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
for (TValue v : values)
|
for (TValue v : values)
|
||||||
if (v.toBoolean() == true)
|
if (v.toBoolean() == true)
|
||||||
return TValue.fromBoolean(!true);
|
return TValue.fromBoolean(!true);
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -58,7 +58,7 @@ public class LogicalNot extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
final boolean arg = values.get(0).toBoolean();
|
final boolean arg = values.get(0).toBoolean();
|
||||||
return TValue.fromBoolean(!arg);
|
return TValue.fromBoolean(!arg);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -58,7 +58,7 @@ public class LogicalNxor extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
int cpt = 0;
|
int cpt = 0;
|
||||||
for (TValue v : values)
|
for (TValue v : values)
|
||||||
if (v.toBoolean() == true)
|
if (v.toBoolean() == true)
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -58,7 +58,7 @@ public class LogicalOr extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
for (TValue v : values)
|
for (TValue v : values)
|
||||||
if (v.toBoolean() == true)
|
if (v.toBoolean() == true)
|
||||||
return TValue.fromBoolean(true);
|
return TValue.fromBoolean(true);
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -58,7 +58,7 @@ public class LogicalXor extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
int cpt = 0;
|
int cpt = 0;
|
||||||
for (TValue v : values)
|
for (TValue v : values)
|
||||||
if (v.toBoolean() == true)
|
if (v.toBoolean() == true)
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -58,7 +58,7 @@ public class Now extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
final long now = System.currentTimeMillis() / 1000L;
|
final long now = System.currentTimeMillis() / 1000L;
|
||||||
return TValue.fromInt((int) now);
|
return TValue.fromInt((int) now);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -58,7 +58,7 @@ public class Ord extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
try {
|
try {
|
||||||
final int codePoint = values.get(0).toString().codePointAt(0);
|
final int codePoint = values.get(0).toString().codePointAt(0);
|
||||||
return TValue.fromInt(codePoint);
|
return TValue.fromInt(codePoint);
|
||||||
|
@ -40,7 +40,7 @@ import java.util.Random;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.text.StringLocated;
|
import net.sourceforge.plantuml.text.StringLocated;
|
||||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
import net.sourceforge.plantuml.tim.EaterException;
|
||||||
import net.sourceforge.plantuml.tim.TContext;
|
import net.sourceforge.plantuml.tim.TContext;
|
||||||
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
import net.sourceforge.plantuml.tim.TFunctionSignature;
|
||||||
import net.sourceforge.plantuml.tim.TMemory;
|
import net.sourceforge.plantuml.tim.TMemory;
|
||||||
@ -61,7 +61,7 @@ public class RandomFunction extends SimpleReturnFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException {
|
||||||
switch (values.size()) {
|
switch (values.size()) {
|
||||||
case 0:
|
case 0:
|
||||||
return TValue.fromInt(random.nextInt(2));
|
return TValue.fromInt(random.nextInt(2));
|
||||||
@ -77,7 +77,7 @@ public class RandomFunction extends SimpleReturnFunction {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
assert false; // Should not append because of canCover()
|
assert false; // Should not append because of canCover()
|
||||||
throw EaterExceptionLocated.located("Error on Random: Too many argument", location);
|
throw new EaterException("Error on Random: Too many argument", location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user