Commit d9841b10 authored by Enteocline's avatar Enteocline

Les fichiers de construction du parseur sont créés par le Makefile, on en n'a plus besoin ici.

parent 089385d4
......@@ -17,6 +17,12 @@ build
org.scala-ide.sdt.core/META-INF/MANIFEST.MF
org.scala-ide.sdt.update-site/site.xml
# Fichiers générés par JavaCC
src/ingame_programming/ParseException.java
src/ingame_programming/Token*
src/ingame_programming/Script*.java
src/ingame_programming/SimpleCharStream.java
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
......
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */
/* JavaCCOptions:KEEP_LINE_COL=null */
package ingame_programming;
/**
* This exception is thrown when parse errors are encountered.
* You can explicitly create objects of this exception type by
* calling the method generateParseException in the generated
* parser.
*
* You can modify this class to customize your error reporting
* mechanisms so long as you retain the public fields.
*/
public class ParseException extends Exception {
/**
* The version identifier for this Serializable class.
* Increment only if the <i>serialized</i> form of the
* class changes.
*/
private static final long serialVersionUID = 1L;
/**
* This constructor is used by the method "generateParseException"
* in the generated parser. Calling this constructor generates
* a new object of this type with the fields "currentToken",
* "expectedTokenSequences", and "tokenImage" set.
*/
public ParseException(Token currentTokenVal,
int[][] expectedTokenSequencesVal,
String[] tokenImageVal
)
{
super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal));
currentToken = currentTokenVal;
expectedTokenSequences = expectedTokenSequencesVal;
tokenImage = tokenImageVal;
}
/**
* The following constructors are for use by you for whatever
* purpose you can think of. Constructing the exception in this
* manner makes the exception behave in the normal way - i.e., as
* documented in the class "Throwable". The fields "errorToken",
* "expectedTokenSequences", and "tokenImage" do not contain
* relevant information. The JavaCC generated code does not use
* these constructors.
*/
public ParseException() {
super();
}
/** Constructor with message. */
public ParseException(String message) {
super(message);
}
/**
* This is the last token that has been consumed successfully. If
* this object has been created due to a parse error, the token
* followng this token will (therefore) be the first error token.
*/
public Token currentToken;
/**
* Each entry in this array is an array of integers. Each array
* of integers represents a sequence of tokens (by their ordinal
* values) that is expected at this point of the parse.
*/
public int[][] expectedTokenSequences;
/**
* This is a reference to the "tokenImage" array of the generated
* parser within which the parse error occurred. This array is
* defined in the generated ...Constants interface.
*/
public String[] tokenImage;
/**
* It uses "currentToken" and "expectedTokenSequences" to generate a parse
* error message and returns it. If this object has been created
* due to a parse error, and you do not catch it (it gets thrown
* from the parser) the correct error message
* gets displayed.
*/
private static String initialise(Token currentToken,
int[][] expectedTokenSequences,
String[] tokenImage) {
String eol = System.getProperty("line.separator", "\n");
StringBuffer expected = new StringBuffer();
int maxSize = 0;
for (int i = 0; i < expectedTokenSequences.length; i++) {
if (maxSize < expectedTokenSequences[i].length) {
maxSize = expectedTokenSequences[i].length;
}
for (int j = 0; j < expectedTokenSequences[i].length; j++) {
expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' ');
}
if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
expected.append("...");
}
expected.append(eol).append(" ");
}
String retval = "Encountered \"";
Token tok = currentToken.next;
for (int i = 0; i < maxSize; i++) {
if (i != 0) retval += " ";
if (tok.kind == 0) {
retval += tokenImage[0];
break;
}
retval += " " + tokenImage[tok.kind];
retval += " \"";
retval += add_escapes(tok.image);
retval += " \"";
tok = tok.next;
}
retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
retval += "." + eol;
if (expectedTokenSequences.length == 1) {
retval += "Was expecting:" + eol + " ";
} else {
retval += "Was expecting one of:" + eol + " ";
}
retval += expected.toString();
return retval;
}
/**
* The end of line string for this machine.
*/
protected String eol = System.getProperty("line.separator", "\n");
/**
* Used to convert raw characters to their escaped version
* when these raw version cannot be used as part of an ASCII
* string literal.
*/
static String add_escapes(String str) {
StringBuffer retval = new StringBuffer();
char ch;
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
{
case 0 :
continue;
case '\b':
retval.append("\\b");
continue;
case '\t':
retval.append("\\t");
continue;
case '\n':
retval.append("\\n");
continue;
case '\f':
retval.append("\\f");
continue;
case '\r':
retval.append("\\r");
continue;
case '\"':
retval.append("\\\"");
continue;
case '\'':
retval.append("\\\'");
continue;
case '\\':
retval.append("\\\\");
continue;
default:
if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
String s = "0000" + Integer.toString(ch, 16);
retval.append("\\u" + s.substring(s.length() - 4, s.length()));
} else {
retval.append(ch);
}
continue;
}
}
return retval.toString();
}
}
/* JavaCC - OriginalChecksum=fdeccd9ec608922b5d520e3c9365cc57 (do not edit this line) */
/* Generated By:JavaCC: Do not edit this line. Script.java */
package ingame_programming;
import java.util.ArrayList;
/** Interpréteur du langage de script */
public class Script implements ScriptConstants {
/**
* Check whether the input is correct.
* @return a ArrayList of String with first element equal to "NULL"
* if the input is wrong
*/
public ArrayList<String> checkInput() {
ArrayList<String> msg = new ArrayList<String>();
try {
msg = Instruction();
} catch(ParseException e) {
msg.add(0, "NULL");
} catch(TokenMgrError e) {
msg.add(0, "NULL");
}
return msg;
}
final public ArrayList<String> Instruction() throws ParseException {
ArrayList<String> target = new ArrayList<String>();
ArrayList<String> tmp = new ArrayList<String>();
Token t;
t = jj_consume_token(VB);
switch (t.image.substring(0, 3)) {
case "att":
target.add("attaquer");
break;
case "pro":
target.add("proteger");
break;
case "soi":
target.add("soigner");
break;
default:
{if (true) throw new ParseException("Invalid instruction: " + t.image);}
}
jj_consume_token(SPACE);
t = jj_consume_token(CTR);
target.add("CTR");
switch (t.image.substring(0,3)) {
case "all":
target.add("allie");
break;
default:
target.add(t.image);
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
jj_consume_token(SPACE);
tmp = Option();
label_1:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
;
break;
default:
jj_la1[0] = jj_gen;
break label_1;
}
jj_consume_token(SPACE);
t = jj_consume_token(LOGIC);
tmp.add(0, "(");
tmp.add(0, t.image.toUpperCase());
tmp.add(")");
target.addAll(tmp);
jj_consume_token(SPACE);
tmp = Option();
}
break;
default:
jj_la1[1] = jj_gen;
;
}
jj_consume_token(0);
target.addAll(tmp);
{if (true) return target;}
throw new Error("Missing return statement in function");
}
/** Détail des options. */
final public ArrayList<String> Option() throws ParseException {
ArrayList<String> tmp1 = new ArrayList<String>();
ArrayList<String> tmp2 = new ArrayList<String>();
Token t;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case CLASS:
t = jj_consume_token(CLASS);
tmp1.add("CLASS");
tmp1.add(t.image);
{if (true) return tmp1;}
break;
case NOMME:
jj_consume_token(NOMME);
jj_consume_token(SPACE);
t = jj_consume_token(NAME);
tmp1.add("NOMME");
tmp1.add(t.image);
{if (true) return tmp1;}
break;
case AVEC:
jj_consume_token(AVEC);
jj_consume_token(SPACE);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case STAT:
t = jj_consume_token(STAT);
tmp1.add("AVEC");
tmp1.add(t.image);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
jj_consume_token(SPACE);
break;
default:
jj_la1[2] = jj_gen;
;
}
t = jj_consume_token(CMP);
tmp1.add(t.image);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
jj_consume_token(SPACE);
break;
default:
jj_la1[3] = jj_gen;
;
}
t = jj_consume_token(VAL);
tmp1.add(t.image);
break;
case HP:
jj_consume_token(HP);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
jj_consume_token(SPACE);
break;
default:
jj_la1[4] = jj_gen;
;
}
t = jj_consume_token(CMP);
tmp1.add("AVEC");
tmp1.add("PV");
tmp1.add(t.image);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
jj_consume_token(SPACE);
break;
default:
jj_la1[5] = jj_gen;
;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case VAL:
t = jj_consume_token(VAL);
tmp1.add(t.image);
break;
case VALPRCT:
t = jj_consume_token(VALPRCT);
tmp1.add("%");
tmp1.add(t.image.substring(0, t.image.length()-1));
break;
default:
jj_la1[6] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
default:
jj_la1[7] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return tmp1;}
break;
case POSSEDANT:
jj_consume_token(POSSEDANT);
jj_consume_token(SPACE);
t = jj_consume_token(ITEM);
tmp1.add("POSSEDANT");
tmp1.add(t.image.toLowerCase().replaceAll("\u00e9|\u00e8|\u00ea","e"));
{if (true) return tmp1;}
break;
case 20:
jj_consume_token(20);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
jj_consume_token(SPACE);
break;
default:
jj_la1[8] = jj_gen;
;
}
tmp1 = Option();
jj_consume_token(SPACE);
t = jj_consume_token(LOGIC);
jj_consume_token(SPACE);
tmp2 = Option();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
jj_consume_token(SPACE);
break;
default:
jj_la1[9] = jj_gen;
;
}
jj_consume_token(21);
tmp1.add(0, "(");
tmp1.add(0, t.image.toUpperCase());
tmp1.add(")");
tmp1.addAll(tmp2);
{if (true) return tmp1;}
break;
case NO:
jj_consume_token(NO);
jj_consume_token(SPACE);
tmp1 = Option();
tmp1.add(0, "NO");
{if (true) return tmp1;}
break;
default:
jj_la1[10] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
throw new Error("Missing return statement in function");
}
/** Generated Token Manager. */
public ScriptTokenManager token_source;
SimpleCharStream jj_input_stream;
/** Current token. */
public Token token;
/** Next token. */
public Token jj_nt;
private int jj_ntk;
private int jj_gen;
final private int[] jj_la1 = new int[11];
static private int[] jj_la1_0;
static {
jj_la1_init_0();
}
private static void jj_la1_init_0() {
jj_la1_0 = new int[] {0x80000,0x80000,0x80000,0x80000,0x80000,0x80000,0x18000,0x180,0x80000,0x80000,0x105c40,};
}
/** Constructor with InputStream. */
public Script(java.io.InputStream stream) {
this(stream, null);
}
/** Constructor with InputStream and supplied encoding */
public Script(java.io.InputStream stream, String encoding) {
try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
token_source = new ScriptTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 11; i++) jj_la1[i] = -1;
}
/** Reinitialise. */
public void ReInit(java.io.InputStream stream) {
ReInit(stream, null);
}
/** Reinitialise. */
public void ReInit(java.io.InputStream stream, String encoding) {
try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
token_source.ReInit(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 11; i++) jj_la1[i] = -1;
}
/** Constructor. */
public Script(java.io.Reader stream) {
jj_input_stream = new SimpleCharStream(stream, 1, 1);
token_source = new ScriptTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 11; i++) jj_la1[i] = -1;
}
/** Reinitialise. */
public void ReInit(java.io.Reader stream) {
jj_input_stream.ReInit(stream, 1, 1);
token_source.ReInit(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 11; i++) jj_la1[i] = -1;
}
/** Constructor with generated Token Manager. */
public Script(ScriptTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 11; i++) jj_la1[i] = -1;
}
/** Reinitialise. */
public void ReInit(ScriptTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 11; i++) jj_la1[i] = -1;
}
private Token jj_consume_token(int kind) throws ParseException {
Token oldToken;
if ((oldToken = token).next != null) token = token.next;
else token = token.next = token_source.getNextToken();
jj_ntk = -1;
if (token.kind == kind) {
jj_gen++;
return token;
}
token = oldToken;
jj_kind = kind;
throw generateParseException();
}
/** Get the next Token. */
final public Token getNextToken() {
if (token.next != null) token = token.next;
else token = token.next = token_source.getNextToken();
jj_ntk = -1;
jj_gen++;
return token;
}
/** Get the specific Token. */
final public Token getToken(int index) {
Token t = token;
for (int i = 0; i < index; i++) {
if (t.next != null) t = t.next;
else t = t.next = token_source.getNextToken();
}
return t;
}
private int jj_ntk() {
if ((jj_nt=token.next) == null)
return (jj_ntk = (token.next=token_source.getNextToken()).kind);
else
return (jj_ntk = jj_nt.kind);
}
private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();
private int[] jj_expentry;
private int jj_kind = -1;
/** Generate ParseException. */
public ParseException generateParseException() {
jj_expentries.clear();
boolean[] la1tokens = new boolean[22];
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
for (int i = 0; i < 11; i++) {
if (jj_la1[i] == jj_gen) {
for (int j = 0; j < 32; j++) {
if ((jj_la1_0[i] & (1<<j)) != 0) {
la1tokens[j] = true;
}
}
}
}
for (int i = 0; i < 22; i++) {
if (la1tokens[i]) {
jj_expentry = new int[1];
jj_expentry[0] = i;
jj_expentries.add(jj_expentry);
}
}
int[][] exptokseq = new int[jj_expentries.size()][];
for (int i = 0; i < jj_expentries.size(); i++) {
exptokseq[i] = jj_expentries.get(i);
}
return new ParseException(token, exptokseq, tokenImage);
}
/** Enable tracing. */
final public void enable_tracing() {
}
/** Disable tracing. */
final public void disable_tracing() {
}
}