summaryrefslogtreecommitdiffstats
path: root/logo/src/xlogo/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'logo/src/xlogo/kernel')
-rw-r--r--logo/src/xlogo/kernel/Kernel.java6
-rw-r--r--logo/src/xlogo/kernel/Primitive.java15
-rw-r--r--logo/src/xlogo/kernel/userspace/ProcedureErrorMessage.java5
-rw-r--r--logo/src/xlogo/kernel/userspace/files/LogoFile.java3
-rw-r--r--logo/src/xlogo/kernel/userspace/procedures/Procedure.java11
5 files changed, 26 insertions, 14 deletions
diff --git a/logo/src/xlogo/kernel/Kernel.java b/logo/src/xlogo/kernel/Kernel.java
index 2a33841..6777df6 100644
--- a/logo/src/xlogo/kernel/Kernel.java
+++ b/logo/src/xlogo/kernel/Kernel.java
@@ -33,7 +33,7 @@ import java.awt.Color;
import xlogo.kernel.userspace.UserSpace;
import xlogo.storage.user.DrawQuality;
-import xlogo.storage.workspace.Language;
+import xlogo.storage.workspace.LogoLanguage;
/**
* Title : XLogo
* Description : XLogo is an interpreter for the Logo
@@ -144,9 +144,9 @@ public class Kernel
app.getDrawPanel().initGraphics();
}
- public void buildPrimitiveTreemap(Language lang)
+ public void buildPrimitiveTreemap(LogoLanguage lang)
{
- primitive.buildPrimitiveTreemap(lang);
+ Primitive.buildPrimitiveTreemap(lang);
}
public String execute(StringBuffer st) throws LogoError
diff --git a/logo/src/xlogo/kernel/Primitive.java b/logo/src/xlogo/kernel/Primitive.java
index 2f01664..b6f2aa5 100644
--- a/logo/src/xlogo/kernel/Primitive.java
+++ b/logo/src/xlogo/kernel/Primitive.java
@@ -46,8 +46,9 @@ import java.math.BigDecimal;
import xlogo.kernel.LoopProperties;
import xlogo.messages.async.history.HistoryMessenger;
import xlogo.storage.WSManager;
-import xlogo.storage.workspace.Language;
+import xlogo.storage.workspace.LogoLanguage;
import xlogo.utils.Utils;
+import xlogo.AppSettings;
import xlogo.Application;
import java.io.*;
@@ -75,6 +76,9 @@ public class Primitive
// Treemap for primitives (better efficiency in searching)
public static TreeMap<String, String> primitives = new TreeMap<String, String>();
+ public static String EXAMPLE_PROGRAM = "repeat 4 [fd 100 rt 90]";
+ public static String TO = "to";
+ public static String END = "end";
public static Stack<LoopProperties> stackLoop = new Stack<LoopProperties>();
@@ -86,7 +90,7 @@ public class Primitive
{
this.app = app;
// build treemap for primitives
- buildPrimitiveTreemap(WSManager.getInstance().getWorkspaceConfigInstance().getLanguage());
+ buildPrimitiveTreemap(AppSettings.getInstance().getLogoLanguage());
}
/**
@@ -143,12 +147,17 @@ public class Primitive
}
// Exécution des primitives
- public static void buildPrimitiveTreemap(Language lang)
+ public static void buildPrimitiveTreemap(LogoLanguage lang)
{
// this.exportPrimCSV();
primitives = new TreeMap<String, String>();
Locale locale = lang.getLocale();
ResourceBundle prim = ResourceBundle.getBundle("primitives", locale);
+
+ EXAMPLE_PROGRAM = prim.getString("pref.highlight.example");
+ TO = prim.getString("pour");
+ END = prim.getString("fin");
+
try
{
BufferedReader bfr = new BufferedReader(new InputStreamReader(
diff --git a/logo/src/xlogo/kernel/userspace/ProcedureErrorMessage.java b/logo/src/xlogo/kernel/userspace/ProcedureErrorMessage.java
index 6e26742..c914305 100644
--- a/logo/src/xlogo/kernel/userspace/ProcedureErrorMessage.java
+++ b/logo/src/xlogo/kernel/userspace/ProcedureErrorMessage.java
@@ -31,6 +31,7 @@ import java.util.ArrayList;
import java.util.Collection;
import xlogo.Logo;
+import xlogo.kernel.Primitive;
import xlogo.kernel.userspace.procedures.ProcedureErrorType;
/**
@@ -98,7 +99,9 @@ public class ProcedureErrorMessage
sb.append(procedureDescription);
sb.append(": ");
- sb.append(Logo.messages.getString(type.getDescription()));
+ sb.append(Logo.messages.getString(type.getDescription())
+ .replace("{to}", Primitive.TO)
+ .replace("{end}", Primitive.END));
return sb.toString();
}
diff --git a/logo/src/xlogo/kernel/userspace/files/LogoFile.java b/logo/src/xlogo/kernel/userspace/files/LogoFile.java
index 4575f73..47eeeb6 100644
--- a/logo/src/xlogo/kernel/userspace/files/LogoFile.java
+++ b/logo/src/xlogo/kernel/userspace/files/LogoFile.java
@@ -43,6 +43,7 @@ import org.apache.logging.log4j.Logger;
import xlogo.Logo;
import xlogo.interfaces.ErrorDetector;
import xlogo.interfaces.ProcedureMapper;
+import xlogo.kernel.Primitive;
import xlogo.kernel.userspace.ProcedureErrorMessage;
import xlogo.kernel.userspace.procedures.ExecutablesContainer;
import xlogo.kernel.userspace.procedures.Procedure;
@@ -515,7 +516,7 @@ public class LogoFile extends StorableDocument implements ExecutablesContainer,
*/
private static String untilEnd(BufferedReader br) throws IOException
{
- String end = Logo.messages.getString("fin").toLowerCase();
+ String end = Primitive.END.toLowerCase();
StringBuffer text = new StringBuffer();
String line;
diff --git a/logo/src/xlogo/kernel/userspace/procedures/Procedure.java b/logo/src/xlogo/kernel/userspace/procedures/Procedure.java
index 2e0ec38..ab50911 100644
--- a/logo/src/xlogo/kernel/userspace/procedures/Procedure.java
+++ b/logo/src/xlogo/kernel/userspace/procedures/Procedure.java
@@ -41,7 +41,6 @@ import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.*;
-import xlogo.Logo;
import xlogo.kernel.Primitive;
import xlogo.utils.Utils;
@@ -338,7 +337,7 @@ public class Procedure
StringBuffer sb = new StringBuffer();
sb.append(comment);
- sb.append(Logo.messages.getString("pour") + " " + name);
+ sb.append(Primitive.TO + " " + name);
for (int j = 0; j < nbparametre; j++)
{
sb.append(" :");
@@ -354,7 +353,7 @@ public class Procedure
}
sb.append("\n");
sb.append(instruction);
- sb.append(Logo.messages.getString("fin"));
+ sb.append(Primitive.END);
sb.append("\n");
// System.out.println("a"+sb+"a");
return new String(sb);
@@ -448,7 +447,7 @@ public class Procedure
{
String token = st.nextToken();
- if (!token.toLowerCase().equals(Logo.messages.getString("pour").toLowerCase()))
+ if (!token.toLowerCase().equals(Primitive.TO.toLowerCase()))
{
addError(ProcedureErrorType.MISSING_TO);
return;
@@ -630,8 +629,8 @@ public class Procedure
private void parseBody(BufferedReader br) throws IOException
{
StringBuffer body = new StringBuffer();
- String to = Logo.messages.getString("pour").toLowerCase() + " ";
- String end = Logo.messages.getString("fin").toLowerCase();
+ String to = Primitive.TO.toLowerCase() + " ";
+ String end = Primitive.END.toLowerCase();
instruction = null;
String line;
String lower;