diff --git a/ArbreAbstrait/Soustraction.java b/ArbreAbstrait/Soustraction.java new file mode 100755 index 0000000000000000000000000000000000000000..c7eed490cd75218e95a6a29325f1d6aceecee703 --- /dev/null +++ b/ArbreAbstrait/Soustraction.java @@ -0,0 +1,26 @@ +/* + * Represent an addition expression node inside the AST. + */ + +public class Soustraction extends Arithmetique { + /** + * Constructor + */ + public Soustraction(Expression operandeGauche, Expression operandeDroite, String fl, int line, int col) { + super(operandeGauche, operandeDroite, fl, line, col); + } + + /** + * Get the binary operator + */ + public String operateur() { + return "-"; + } + + /** + * Accepts a AST visitor + */ + Object accept(ASTVisitor visitor){ + return visitor.visit(this); + } +} diff --git a/HepialLexer.java b/HepialLexer.java new file mode 100644 index 0000000000000000000000000000000000000000..651fcdc2b81ca88aefd25c0b1659a3dac433e97b --- /dev/null +++ b/HepialLexer.java @@ -0,0 +1,914 @@ +/* The following code was generated by JFlex 1.6.1 */ + +import java_cup.runtime.*; +import java.util.*; + + +/** + * This class is a scanner generated by + * <a href="http://www.jflex.de/">JFlex</a> 1.6.1 + * from the specification file <tt>hepial.flex</tt> + */ +class HepialLexer implements java_cup.runtime.Scanner { + + /** This character denotes the end of file */ + public static final int YYEOF = -1; + + /** initial size of the lookahead buffer */ + private static final int ZZ_BUFFERSIZE = 16384; + + /** lexical states */ + public static final int YYINITIAL = 0; + + /** + * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l + * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l + * at the beginning of a line + * l is of the form l = 2*k, k a non negative integer + */ + private static final int ZZ_LEXSTATE[] = { + 0, 0 + }; + + /** + * Translates characters to character classes + */ + private static final String ZZ_CMAP_PACKED = + "\11\0\1\16\1\15\1\15\1\15\1\15\22\0\1\16\1\0\1\3"+ + "\5\0\1\7\1\10\1\45\1\43\1\4\1\44\1\13\1\14\12\2"+ + "\1\0\1\5\1\46\1\6\1\47\2\0\32\1\1\11\1\0\1\12"+ + "\3\0\1\23\1\27\1\35\1\26\1\25\1\32\1\22\1\1\1\33"+ + "\2\1\1\37\1\24\1\34\1\21\1\17\1\40\1\20\1\36\1\31"+ + "\1\30\1\41\1\1\1\42\2\1\1\0\1\16\10\0\1\15\32\0"+ + "\1\16\u15df\0\1\16\u097f\0\13\16\35\0\1\15\1\15\5\0\1\16"+ + "\57\0\1\16\u0fa0\0\1\16\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\ud00f\0"; + + /** + * Translates characters to character classes + */ + private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); + + /** + * Translates DFA states to action switch labels. + */ + private static final int [] ZZ_ACTION = zzUnpackAction(); + + private static final String ZZ_ACTION_PACKED_0 = + "\1\0\1\1\1\2\1\0\1\3\1\4\1\5\1\6"+ + "\1\7\1\10\1\11\1\0\1\12\1\13\2\1\1\14"+ + "\12\1\1\15\1\16\1\17\1\20\1\21\1\22\1\23"+ + "\1\24\1\13\2\1\1\25\1\1\1\26\11\1\1\27"+ + "\2\1\1\30\1\31\1\32\14\1\1\33\5\1\1\34"+ + "\7\1\1\35\6\1\1\36\1\37\1\1\1\40\6\1"+ + "\1\41\3\1\1\42\1\1\1\43\2\1\1\44\1\45"+ + "\3\1\1\46\6\1\1\47\1\50\1\51\3\1\1\52"+ + "\1\53\2\1\1\54\1\1\1\55\1\56"; + + private static int [] zzUnpackAction() { + int [] result = new int[134]; + int offset = 0; + offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAction(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /** + * Translates a state to a row index in the transition table + */ + private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); + + private static final String ZZ_ROWMAP_PACKED_0 = + "\0\0\0\50\0\120\0\170\0\240\0\240\0\310\0\240"+ + "\0\240\0\240\0\240\0\360\0\u0118\0\u0140\0\u0168\0\u0190"+ + "\0\u01b8\0\u01e0\0\u0208\0\u0230\0\u0258\0\u0280\0\u02a8\0\u02d0"+ + "\0\u02f8\0\u0320\0\u0348\0\240\0\240\0\240\0\u0370\0\u0398"+ + "\0\u03c0\0\240\0\240\0\u03e8\0\u0410\0\u0438\0\50\0\u0460"+ + "\0\50\0\u0488\0\u04b0\0\u04d8\0\u0500\0\u0528\0\u0550\0\u0578"+ + "\0\u05a0\0\u05c8\0\u05f0\0\u0618\0\u0640\0\240\0\240\0\240"+ + "\0\u0668\0\u0690\0\u06b8\0\u06e0\0\u0708\0\u0730\0\u0758\0\u0780"+ + "\0\u07a8\0\u07d0\0\u07f8\0\u0820\0\50\0\u0848\0\u0870\0\u0898"+ + "\0\u08c0\0\u08e8\0\50\0\u0910\0\u0938\0\u0960\0\u0988\0\u09b0"+ + "\0\u09d8\0\u0a00\0\50\0\u0a28\0\u0a50\0\u0a78\0\u0aa0\0\u0ac8"+ + "\0\u0af0\0\50\0\50\0\u0b18\0\50\0\u0b40\0\u0b68\0\u0b90"+ + "\0\u0bb8\0\u0be0\0\u0c08\0\50\0\u0c30\0\u0c58\0\u0c80\0\50"+ + "\0\u0ca8\0\50\0\u0cd0\0\u0cf8\0\50\0\50\0\u0d20\0\u0d48"+ + "\0\u0d70\0\50\0\u0d98\0\u0dc0\0\u0de8\0\u0e10\0\u0e38\0\u0e60"+ + "\0\50\0\50\0\50\0\u0e88\0\u0eb0\0\u0ed8\0\50\0\50"+ + "\0\u0f00\0\u0f28\0\50\0\u0f50\0\50\0\50"; + + private static int [] zzUnpackRowMap() { + int [] result = new int[134]; + int offset = 0; + offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackRowMap(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int high = packed.charAt(i++) << 16; + result[j++] = high | packed.charAt(i++); + } + return j; + } + + /** + * The transition table of the DFA + */ + private static final int [] ZZ_TRANS = zzUnpackTrans(); + + private static final String ZZ_TRANS_PACKED_0 = + "\1\0\1\2\1\3\1\4\1\5\1\6\1\7\1\10"+ + "\1\11\1\12\1\13\1\14\1\15\2\16\1\17\1\2"+ + "\1\20\1\2\1\21\1\2\1\22\1\23\1\24\1\2"+ + "\1\25\1\26\1\2\1\27\1\30\1\31\1\32\1\2"+ + "\1\33\1\2\1\34\1\35\1\36\1\37\1\40\1\0"+ + "\2\2\14\0\24\2\7\0\1\3\45\0\3\4\1\41"+ + "\44\4\56\0\1\42\54\0\1\43\50\0\1\44\50\0"+ + "\2\16\32\0\2\2\14\0\1\2\1\45\1\46\21\2"+ + "\6\0\2\2\14\0\11\2\1\47\12\2\6\0\2\2"+ + "\14\0\20\2\1\50\3\2\6\0\2\2\14\0\12\2"+ + "\1\51\2\2\1\52\1\53\5\2\6\0\2\2\14\0"+ + "\6\2\1\54\15\2\6\0\2\2\14\0\2\2\1\55"+ + "\21\2\6\0\2\2\14\0\4\2\1\56\17\2\6\0"+ + "\2\2\14\0\4\2\1\57\7\2\1\60\7\2\6\0"+ + "\2\2\14\0\2\2\1\61\21\2\6\0\2\2\14\0"+ + "\2\2\1\62\21\2\6\0\2\2\14\0\14\2\1\63"+ + "\7\2\6\0\2\2\14\0\14\2\1\64\7\2\6\0"+ + "\2\2\14\0\1\2\1\65\22\2\13\0\1\66\40\0"+ + "\1\67\6\0\1\70\44\0\1\4\44\0\15\44\1\0"+ + "\32\44\1\0\2\2\14\0\2\2\1\71\21\2\6\0"+ + "\2\2\14\0\11\2\1\72\12\2\6\0\2\2\14\0"+ + "\2\2\1\73\15\2\1\74\3\2\6\0\2\2\14\0"+ + "\12\2\1\75\11\2\6\0\2\2\14\0\1\2\1\76"+ + "\22\2\6\0\2\2\14\0\10\2\1\77\13\2\6\0"+ + "\2\2\14\0\2\2\1\100\21\2\6\0\2\2\14\0"+ + "\15\2\1\101\6\2\6\0\2\2\14\0\11\2\1\102"+ + "\2\2\1\103\7\2\6\0\2\2\14\0\15\2\1\104"+ + "\6\2\6\0\2\2\14\0\15\2\1\105\6\2\6\0"+ + "\2\2\14\0\15\2\1\106\6\2\6\0\2\2\14\0"+ + "\15\2\1\107\6\2\6\0\2\2\14\0\1\2\1\110"+ + "\22\2\6\0\2\2\14\0\4\2\1\111\17\2\6\0"+ + "\2\2\14\0\3\2\1\112\20\2\6\0\2\2\14\0"+ + "\1\2\1\113\22\2\6\0\2\2\14\0\1\2\1\114"+ + "\22\2\6\0\2\2\14\0\4\2\1\115\17\2\6\0"+ + "\2\2\14\0\14\2\1\116\7\2\6\0\2\2\14\0"+ + "\14\2\1\117\7\2\6\0\2\2\14\0\11\2\1\120"+ + "\12\2\6\0\2\2\14\0\20\2\1\121\3\2\6\0"+ + "\2\2\14\0\12\2\1\122\11\2\6\0\2\2\14\0"+ + "\23\2\1\123\6\0\2\2\14\0\1\2\1\124\22\2"+ + "\6\0\2\2\14\0\1\125\11\2\1\126\4\2\1\127"+ + "\4\2\6\0\2\2\14\0\17\2\1\130\4\2\6\0"+ + "\2\2\14\0\2\2\1\131\21\2\6\0\2\2\14\0"+ + "\6\2\1\132\15\2\6\0\2\2\14\0\14\2\1\133"+ + "\7\2\6\0\2\2\14\0\1\2\1\134\22\2\6\0"+ + "\2\2\14\0\17\2\1\135\4\2\6\0\2\2\14\0"+ + "\15\2\1\136\6\2\6\0\2\2\14\0\6\2\1\137"+ + "\15\2\6\0\2\2\14\0\1\2\1\140\22\2\6\0"+ + "\2\2\14\0\12\2\1\141\11\2\6\0\2\2\14\0"+ + "\6\2\1\142\15\2\6\0\2\2\14\0\21\2\1\143"+ + "\2\2\6\0\2\2\14\0\6\2\1\144\15\2\6\0"+ + "\2\2\14\0\1\2\1\145\1\146\21\2\6\0\2\2"+ + "\14\0\4\2\1\147\17\2\6\0\2\2\14\0\14\2"+ + "\1\150\7\2\6\0\2\2\14\0\12\2\1\151\11\2"+ + "\6\0\2\2\14\0\15\2\1\152\6\2\6\0\2\2"+ + "\14\0\4\2\1\153\17\2\6\0\2\2\14\0\12\2"+ + "\1\154\11\2\6\0\2\2\14\0\1\2\1\155\22\2"+ + "\6\0\2\2\14\0\6\2\1\156\15\2\6\0\2\2"+ + "\14\0\1\157\23\2\6\0\2\2\14\0\6\2\1\160"+ + "\15\2\6\0\2\2\14\0\11\2\1\161\12\2\6\0"+ + "\2\2\14\0\3\2\1\162\20\2\6\0\2\2\14\0"+ + "\11\2\1\163\12\2\6\0\2\2\14\0\15\2\1\164"+ + "\6\2\6\0\2\2\14\0\4\2\1\165\17\2\6\0"+ + "\2\2\14\0\5\2\1\166\16\2\6\0\2\2\14\0"+ + "\7\2\1\167\14\2\6\0\2\2\14\0\1\2\1\170"+ + "\22\2\6\0\2\2\14\0\15\2\1\171\6\2\6\0"+ + "\2\2\14\0\6\2\1\172\15\2\6\0\2\2\14\0"+ + "\1\2\1\173\22\2\6\0\2\2\14\0\12\2\1\174"+ + "\11\2\6\0\2\2\14\0\15\2\1\175\6\2\6\0"+ + "\2\2\14\0\5\2\1\176\16\2\6\0\2\2\14\0"+ + "\6\2\1\177\15\2\6\0\2\2\14\0\3\2\1\200"+ + "\20\2\6\0\2\2\14\0\21\2\1\201\2\2\6\0"+ + "\2\2\14\0\12\2\1\202\11\2\6\0\2\2\14\0"+ + "\6\2\1\203\15\2\6\0\2\2\14\0\11\2\1\204"+ + "\12\2\6\0\2\2\14\0\6\2\1\205\15\2\6\0"+ + "\2\2\14\0\6\2\1\206\15\2\5\0"; + + private static int [] zzUnpackTrans() { + int [] result = new int[3960]; + int offset = 0; + offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackTrans(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + + /* error messages for the codes above */ + private static final String ZZ_ERROR_MSG[] = { + "Unknown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + + /** + * ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code> + */ + private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); + + private static final String ZZ_ATTRIBUTE_PACKED_0 = + "\1\0\2\1\1\0\2\11\1\1\4\11\1\0\17\1"+ + "\3\11\3\1\2\11\22\1\3\11\116\1"; + + private static int [] zzUnpackAttribute() { + int [] result = new int[134]; + int offset = 0; + offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAttribute(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + /** the input device */ + private java.io.Reader zzReader; + + /** the current state of the DFA */ + private int zzState; + + /** the current lexical state */ + private int zzLexicalState = YYINITIAL; + + /** this buffer contains the current text to be matched and is + the source of the yytext() string */ + private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; + + /** the textposition at the last accepting state */ + private int zzMarkedPos; + + /** the current text position in the buffer */ + private int zzCurrentPos; + + /** startRead marks the beginning of the yytext() string in the buffer */ + private int zzStartRead; + + /** endRead marks the last character in the buffer, that has been read + from input */ + private int zzEndRead; + + /** number of newlines encountered up to the start of the matched text */ + private int yyline; + + /** the number of characters up to the start of the matched text */ + private int yychar; + + /** + * the number of characters from the last newline up to the start of the + * matched text + */ + private int yycolumn; + + /** + * zzAtBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean zzAtBOL = true; + + /** zzAtEOF == true <=> the scanner is at the EOF */ + private boolean zzAtEOF; + + /** denotes if the user-EOF-code has already been executed */ + private boolean zzEOFDone; + + /** + * The number of occupied positions in zzBuffer beyond zzEndRead. + * When a lead/high surrogate has been read from the input stream + * into the final zzBuffer position, this will have a value of 1; + * otherwise, it will have a value of 0. + */ + private int zzFinalHighSurrogate = 0; + + /* user code: */ + +// Print parsing errors +public void yyerror() { + System.out.println("error line " +yyline + " column " +yycolumn + + " " +yytext()); +} + + + + /** + * Creates a new scanner + * + * @param in the java.io.Reader to read input from. + */ + HepialLexer(java.io.Reader in) { + this.zzReader = in; + } + + + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char [] zzUnpackCMap(String packed) { + char [] map = new char[0x110000]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < 182) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do map[j++] = value; while (--count > 0); + } + return map; + } + + + /** + * Refills the input buffer. + * + * @return <code>false</code>, iff there was new input. + * + * @exception java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { + + /* first: make room (if you can) */ + if (zzStartRead > 0) { + zzEndRead += zzFinalHighSurrogate; + zzFinalHighSurrogate = 0; + System.arraycopy(zzBuffer, zzStartRead, + zzBuffer, 0, + zzEndRead-zzStartRead); + + /* translate stored positions */ + zzEndRead-= zzStartRead; + zzCurrentPos-= zzStartRead; + zzMarkedPos-= zzStartRead; + zzStartRead = 0; + } + + /* is the buffer big enough? */ + if (zzCurrentPos >= zzBuffer.length - zzFinalHighSurrogate) { + /* if not: blow it up */ + char newBuffer[] = new char[zzBuffer.length*2]; + System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); + zzBuffer = newBuffer; + zzEndRead += zzFinalHighSurrogate; + zzFinalHighSurrogate = 0; + } + + /* fill the buffer with new input */ + int requested = zzBuffer.length - zzEndRead; + int numRead = zzReader.read(zzBuffer, zzEndRead, requested); + + /* not supposed to occur according to specification of java.io.Reader */ + if (numRead == 0) { + throw new java.io.IOException("Reader returned 0 characters. See JFlex examples for workaround."); + } + if (numRead > 0) { + zzEndRead += numRead; + /* If numRead == requested, we might have requested to few chars to + encode a full Unicode character. We assume that a Reader would + otherwise never return half characters. */ + if (numRead == requested) { + if (Character.isHighSurrogate(zzBuffer[zzEndRead - 1])) { + --zzEndRead; + zzFinalHighSurrogate = 1; + } + } + /* potentially more input available */ + return false; + } + + /* numRead < 0 ==> end of stream */ + return true; + } + + + /** + * Closes the input stream. + */ + public final void yyclose() throws java.io.IOException { + zzAtEOF = true; /* indicate end of file */ + zzEndRead = zzStartRead; /* invalidate buffer */ + + if (zzReader != null) + zzReader.close(); + } + + + /** + * Resets the scanner to read from a new input stream. + * Does not close the old reader. + * + * All internal variables are reset, the old input stream + * <b>cannot</b> be reused (internal buffer is discarded and lost). + * Lexical state is set to <tt>ZZ_INITIAL</tt>. + * + * Internal scan buffer is resized down to its initial length, if it has grown. + * + * @param reader the new input stream + */ + public final void yyreset(java.io.Reader reader) { + zzReader = reader; + zzAtBOL = true; + zzAtEOF = false; + zzEOFDone = false; + zzEndRead = zzStartRead = 0; + zzCurrentPos = zzMarkedPos = 0; + zzFinalHighSurrogate = 0; + yyline = yychar = yycolumn = 0; + zzLexicalState = YYINITIAL; + if (zzBuffer.length > ZZ_BUFFERSIZE) + zzBuffer = new char[ZZ_BUFFERSIZE]; + } + + + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } + + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } + + + /** + * Returns the text matched by the current regular expression. + */ + public final String yytext() { + return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead ); + } + + + /** + * Returns the character at position <tt>pos</tt> from the + * matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. + * A value from 0 to yylength()-1. + * + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBuffer[zzStartRead+pos]; + } + + + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos-zzStartRead; + } + + + /** + * Reports an error that occured while scanning. + * + * In a wellformed scanner (no or only correct usage of + * yypushback(int) and a match-all fallback rule) this method + * will only be called with things that "Can't Possibly Happen". + * If this method is called, something is seriously wrong + * (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done + * in error fallback rules. + * + * @param errorCode the code of the errormessage to display + */ + private void zzScanError(int errorCode) { + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } + catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } + + throw new Error(message); + } + + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ + public void yypushback(int number) { + if ( number > yylength() ) + zzScanError(ZZ_PUSHBACK_2BIG); + + zzMarkedPos -= number; + } + + + /** + * Contains user EOF-code, which will be executed exactly once, + * when the end of file is reached + */ + private void zzDoEOF() throws java.io.IOException { + if (!zzEOFDone) { + zzEOFDone = true; + yyclose(); + } + } + + + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception java.io.IOException if any I/O-Error occurs + */ + public java_cup.runtime.Symbol next_token() throws java.io.IOException { + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + char [] zzBufferL = zzBuffer; + char [] zzCMapL = ZZ_CMAP; + + int [] zzTransL = ZZ_TRANS; + int [] zzRowMapL = ZZ_ROWMAP; + int [] zzAttrL = ZZ_ATTRIBUTE; + + while (true) { + zzMarkedPosL = zzMarkedPos; + + boolean zzR = false; + int zzCh; + int zzCharCount; + for (zzCurrentPosL = zzStartRead ; + zzCurrentPosL < zzMarkedPosL ; + zzCurrentPosL += zzCharCount ) { + zzCh = Character.codePointAt(zzBufferL, zzCurrentPosL, zzMarkedPosL); + zzCharCount = Character.charCount(zzCh); + switch (zzCh) { + case '\u000B': + case '\u000C': + case '\u0085': + case '\u2028': + case '\u2029': + yyline++; + yycolumn = 0; + zzR = false; + break; + case '\r': + yyline++; + yycolumn = 0; + zzR = true; + break; + case '\n': + if (zzR) + zzR = false; + else { + yyline++; + yycolumn = 0; + } + break; + default: + zzR = false; + yycolumn += zzCharCount; + } + } + + if (zzR) { + // peek one character ahead if it is \n (if we have counted one line too much) + boolean zzPeek; + if (zzMarkedPosL < zzEndReadL) + zzPeek = zzBufferL[zzMarkedPosL] == '\n'; + else if (zzAtEOF) + zzPeek = false; + else { + boolean eof = zzRefill(); + zzEndReadL = zzEndRead; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + if (eof) + zzPeek = false; + else + zzPeek = zzBufferL[zzMarkedPosL] == '\n'; + } + if (zzPeek) yyline--; + } + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = ZZ_LEXSTATE[zzLexicalState]; + + // set up zzAction for empty match case: + int zzAttributes = zzAttrL[zzState]; + if ( (zzAttributes & 1) == 1 ) { + zzAction = zzState; + } + + + zzForAction: { + while (true) { + + if (zzCurrentPosL < zzEndReadL) { + zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL, zzEndReadL); + zzCurrentPosL += Character.charCount(zzInput); + } + else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } + else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + zzCurrentPosL = zzCurrentPos; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + zzEndReadL = zzEndRead; + if (eof) { + zzInput = YYEOF; + break zzForAction; + } + else { + zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL, zzEndReadL); + zzCurrentPosL += Character.charCount(zzInput); + } + } + int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; + if (zzNext == -1) break zzForAction; + zzState = zzNext; + + zzAttributes = zzAttrL[zzState]; + if ( (zzAttributes & 1) == 1 ) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ( (zzAttributes & 8) == 8 ) break zzForAction; + } + + } + } + + // store back cached position + zzMarkedPos = zzMarkedPosL; + + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + zzDoEOF(); + { return new java_cup.runtime.Symbol(sym.EOF); } + } + else { + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 1: + { return new Symbol(sym.IDENT, yyline, yycolumn, yytext()); + } + case 47: break; + case 2: + { return new Symbol(sym.INTEGERCONST, yyline, yycolumn, Integer.parseInt(yytext())); + } + case 48: break; + case 3: + { return new Symbol(sym.COMMA, yyline, yycolumn); + } + case 49: break; + case 4: + { return new Symbol(sym.SEMICOLON, yyline, yycolumn); + } + case 50: break; + case 5: + { return new Symbol(sym.EQUAL, yyline, yycolumn); + } + case 51: break; + case 6: + { return new Symbol(sym.OPENPARENT, yyline, yycolumn); + } + case 52: break; + case 7: + { return new Symbol(sym.CLOSEPARENT, yyline, yycolumn); + } + case 53: break; + case 8: + { return new Symbol(sym.OPENBRACK, yyline, yycolumn); + } + case 54: break; + case 9: + { return new Symbol(sym.CLOSEBRACK, yyline, yycolumn); + } + case 55: break; + case 10: + { return new Symbol(sym.DIVIDE, yyline, yycolumn); + } + case 56: break; + case 11: + { ; + } + case 57: break; + case 12: + { return new Symbol(sym.TO, yyline, yycolumn); + } + case 58: break; + case 13: + { return new Symbol(sym.PLUS, yyline, yycolumn); + } + case 59: break; + case 14: + { return new Symbol(sym.MINUS, yyline, yycolumn); + } + case 60: break; + case 15: + { return new Symbol(sym.TIMES, yyline, yycolumn); + } + case 61: break; + case 16: + { return new Symbol(sym.INF, yyline, yycolumn); + } + case 62: break; + case 17: + { return new Symbol(sym.SUP, yyline, yycolumn); + } + case 63: break; + case 18: + { return new Symbol(sym.STRINGCONST, yyline, yycolumn, yytext()); + } + case 64: break; + case 19: + { return new Symbol(sym.EQUALS, yyline, yycolumn); + } + case 65: break; + case 20: + { return new Symbol(sym.DOUBLEPOINTS, yyline, yycolumn); + } + case 66: break; + case 21: + { return new Symbol(sym.OR, yyline, yycolumn); + } + case 67: break; + case 22: + { return new Symbol(sym.AND, yyline, yycolumn); + } + case 68: break; + case 23: + { return new Symbol(sym.IF, yyline, yycolumn); + } + case 69: break; + case 24: + { return new Symbol(sym.INFEQUAL, yyline, yycolumn); + } + case 70: break; + case 25: + { return new Symbol(sym.DIFF, yyline, yycolumn); + } + case 71: break; + case 26: + { return new Symbol(sym.SUPEQUAL, yyline, yycolumn); + } + case 72: break; + case 27: + { return new Symbol(sym.NOT, yyline, yycolumn); + } + case 73: break; + case 28: + { return new Symbol(sym.FOR, yyline, yycolumn); + } + case 74: break; + case 29: + { return new Symbol(sym.FALSE, yyline, yycolumn); + } + case 75: break; + case 30: + { return new Symbol(sym.READ, yyline, yycolumn); + } + case 76: break; + case 31: + { return new Symbol(sym.TRUE, yyline, yycolumn); + } + case 77: break; + case 32: + { return new Symbol(sym.THEN, yyline, yycolumn); + } + case 78: break; + case 33: + { return new Symbol(sym.DO, yyline, yycolumn); + } + case 79: break; + case 34: + { return new Symbol(sym.ENDIF, yyline, yycolumn); + } + case 80: break; + case 35: + { return new Symbol(sym.ELSE, yyline, yycolumn); + } + case 81: break; + case 36: + { return new Symbol(sym.TINTEGER, yyline, yycolumn); + } + case 82: break; + case 37: + { return new Symbol(sym.WRITE, yyline, yycolumn); + } + case 83: break; + case 38: + { return new Symbol(sym.ENDPRG, yyline, yycolumn); + } + case 84: break; + case 39: + { return new Symbol(sym.TBOOLEAN, yyline, yycolumn); + } + case 85: break; + case 40: + { return new Symbol(sym.WHILE, yyline, yycolumn); + } + case 86: break; + case 41: + { return new Symbol(sym.ENDFOR, yyline, yycolumn); + } + case 87: break; + case 42: + { return new Symbol(sym.FROM, yyline, yycolumn); + } + case 88: break; + case 43: + { return new Symbol(sym.STARTPRG, yyline, yycolumn); + } + case 89: break; + case 44: + { return new Symbol(sym.PRG, yyline, yycolumn); + } + case 90: break; + case 45: + { return new Symbol(sym.CONSTANT, yyline, yycolumn); + } + case 91: break; + case 46: + { return new Symbol(sym.ENDWHILE, yyline, yycolumn); + } + case 92: break; + default: + zzScanError(ZZ_NO_MATCH); + } + } + } + } + + +} diff --git a/Tests/test_base_with_sementic_issue.input b/Tests/test_base_with_sementic_issue.input index 300869b87d53141c8eca3afba74c27320a02b4d9..675861eeb2c2108e9efe7715e5457c7c09686a2d 100755 --- a/Tests/test_base_with_sementic_issue.input +++ b/Tests/test_base_with_sementic_issue.input @@ -2,5 +2,5 @@ programme Program debutprg b = 3; - c = c + 2; + c = c - 2; finprg diff --git a/Visitors/ASTVisitor.java b/Visitors/ASTVisitor.java index 074c63f43f7f2959b096201759755052f4e08b2d..d9fae68287e56c6741d339c68b01bf456e69cafb 100755 --- a/Visitors/ASTVisitor.java +++ b/Visitors/ASTVisitor.java @@ -35,7 +35,7 @@ public interface ASTVisitor { // Object visit(Parentheses node); // Object visit(Pour node); // Object visit(Produit node); -// Object visit(Soustraction node); + Object visit(Soustraction node); // Object visit(SupEgal node); // Object visit(Superieur node); // Object visit(Tantque node); diff --git a/Visitors/ByteCodeGenerator.java b/Visitors/ByteCodeGenerator.java index 0cf76c22f20af5515b1c83615a448fedcbbe4a2b..37c1db83adbb5476d3b678d99d903872515dc975 100755 --- a/Visitors/ByteCodeGenerator.java +++ b/Visitors/ByteCodeGenerator.java @@ -60,7 +60,7 @@ public class ByteCodeGenerator implements ASTVisitor{ // public Object visit(Relation node) { return null; } -// public Object visit(Soustraction node) { return null; } + public Object visit(Soustraction node) { return null; } // public Object visit(SupEgal node) { return null; } diff --git a/Visitors/SemanticAnalyzer.java b/Visitors/SemanticAnalyzer.java index b8e79053169d8350c891eeea72a929d560572b22..579a7e0818b97ec64912220e4939ec4759c02d86 100755 --- a/Visitors/SemanticAnalyzer.java +++ b/Visitors/SemanticAnalyzer.java @@ -62,7 +62,7 @@ public class SemanticAnalyzer implements ASTVisitor { // public Object visit(Relation node) { return null; } -// public Object visit(Soustraction node) { return null; } + public Object visit(Soustraction node) { return null; } // public Object visit(SupEgal node) { return null; } diff --git a/Visitors/SourceCodeGenerator.java b/Visitors/SourceCodeGenerator.java index ed13c7329916d2c9a8988d58b160c2bd785af8dc..96fb77687d89aab77c1b415f87b4134c975565e9 100755 --- a/Visitors/SourceCodeGenerator.java +++ b/Visitors/SourceCodeGenerator.java @@ -237,12 +237,12 @@ public class SourceCodeGenerator implements ASTVisitor{ // return null; // } // -// public Object visit(Soustraction node){ -// node.getGauche().accept(this); -// code += " - "; -// node.getDroite().accept(this); -// return null; -// } + public Object visit(Soustraction node){ + node.getGauche().accept(this); + code += " - "; + node.getDroite().accept(this); + return null; + } // // public Object visit(SupEgal node){ // node.getGauche().accept(this); diff --git a/hepial.cup b/hepial.cup index ad24521e044bbc9460f42a7f247be4a0819bb269..bb16b12927ef8cc6972e3db16a89882f85d22462 100755 --- a/hepial.cup +++ b/hepial.cup @@ -11,7 +11,6 @@ terminal CLOSEPARENT, COMMA, EQUAL, DOUBLEPOINTS, OPENBRACK, CLOSEBRACK; terminal READ, WRITE, IF, THEN, ELSE, ENDIF, WHILE, DO, ENDWHILE; terminal FOR, FROM, TO, ENDFOR, TRUE, FALSE, PLUS, MINUS, TIMES, DIVIDE; terminal EQUALS, DIFF, INF, INFEQUAL, SUP, SUPEQUAL, AND, OR, NOT, UMINUS; - terminal String IDENT, STRINGCONST, TINTEGER, TBOOLEAN; terminal int INTEGERCONST; @@ -77,7 +76,7 @@ type ::= TINTEGER {: :} declar_const ::= CONSTANT type IDENT EQUAL expr SEMICOLON {: :}; op_bin ::= expr:a PLUS expr:b {: RESULT = new Addition(a, b, "", aleft, aright); :} - | expr MINUS expr {: :} + | expr:a MINUS expr:b {: RESULT = new Soustraction(a, b, "", aleft, aright); :} | expr TIMES expr {: :} | expr DIVIDE expr {: :} | expr AND expr {: :} diff --git a/parser.java b/parser.java new file mode 100644 index 0000000000000000000000000000000000000000..cd55c68f35a9e45e397983541a432b2f6433a308 --- /dev/null +++ b/parser.java @@ -0,0 +1,949 @@ + +//---------------------------------------------------- +// The following code was generated by CUP v0.11a beta 20060608 +// Wed Nov 23 18:32:15 CET 2022 +//---------------------------------------------------- + +import java_cup.runtime.*; +import java.util.Vector; +import java.io.*; +import java.util.*; + +/** CUP v0.11a beta 20060608 generated parser. + * @version Wed Nov 23 18:32:15 CET 2022 + */ +public class parser extends java_cup.runtime.lr_parser { + + /** Default constructor. */ + public parser() {super();} + + /** Constructor which sets the default scanner. */ + public parser(java_cup.runtime.Scanner s) {super(s);} + + /** Constructor which sets the default scanner. */ + public parser(java_cup.runtime.Scanner s, java_cup.runtime.SymbolFactory sf) {super(s,sf);} + + /** Production table. */ + protected static final short _production_table[][] = + unpackFromStrings(new String[] { + "\000\067\000\002\002\007\000\002\002\004\000\002\003" + + "\004\000\002\004\003\000\002\007\002\000\002\007\004" + + "\000\002\010\003\000\002\010\003\000\002\011\005\000" + + "\002\030\003\000\002\030\005\000\002\031\003\000\002" + + "\031\003\000\002\012\010\000\002\026\005\000\002\026" + + "\005\000\002\026\005\000\002\026\005\000\002\026\005" + + "\000\002\026\005\000\002\027\005\000\002\027\005\000" + + "\002\027\005\000\002\027\005\000\002\027\005\000\002" + + "\027\005\000\002\025\004\000\002\025\004\000\002\015" + + "\003\000\002\015\003\000\002\015\003\000\002\015\003" + + "\000\002\014\003\000\002\013\003\000\002\013\003\000" + + "\002\013\003\000\002\013\003\000\002\013\005\000\002" + + "\005\003\000\002\006\002\000\002\006\004\000\002\023" + + "\003\000\002\023\003\000\002\023\003\000\002\023\003" + + "\000\002\023\003\000\002\023\003\000\002\024\006\000" + + "\002\021\005\000\002\021\005\000\002\022\005\000\002" + + "\020\011\000\002\020\007\000\002\017\007\000\002\016" + + "\013" }); + + /** Access to production table. */ + public short[][] production_table() {return _production_table;} + + /** Parse-action table. */ + protected static final short[][] _action_table = + unpackFromStrings(new String[] { + "\000\156\000\004\004\005\001\002\000\004\002\160\001" + + "\002\000\004\055\157\001\002\000\012\005\ufffd\007\ufffd" + + "\057\ufffd\060\ufffd\001\002\000\012\005\ufffe\007\141\057" + + "\136\060\144\001\002\000\004\005\011\001\002\000\020" + + "\006\uffda\020\uffda\021\uffda\022\uffda\026\uffda\031\uffda\055" + + "\uffda\001\002\000\004\006\135\001\002\000\030\006\uffdb" + + "\020\014\021\025\022\024\024\uffdb\025\uffdb\026\015\030" + + "\uffdb\031\017\034\uffdb\055\016\001\002\000\004\055\133" + + "\001\002\000\020\011\043\035\037\036\044\040\032\053" + + "\046\055\016\061\036\001\002\000\046\010\uffe1\012\uffe1" + + "\014\uffe1\023\uffe1\027\uffe1\033\uffe1\037\uffe1\040\uffe1\041" + + "\uffe1\042\uffe1\043\uffe1\044\uffe1\045\uffe1\046\uffe1\047\uffe1" + + "\050\uffe1\051\uffe1\052\uffe1\001\002\000\004\055\117\001" + + "\002\000\030\006\uffd5\020\uffd5\021\uffd5\022\uffd5\024\uffd5" + + "\025\uffd5\026\uffd5\030\uffd5\031\uffd5\034\uffd5\055\uffd5\001" + + "\002\000\030\006\uffd6\020\uffd6\021\uffd6\022\uffd6\024\uffd6" + + "\025\uffd6\026\uffd6\030\uffd6\031\uffd6\034\uffd6\055\uffd6\001" + + "\002\000\004\014\114\001\002\000\030\006\uffd4\020\uffd4" + + "\021\uffd4\022\uffd4\024\uffd4\025\uffd4\026\uffd4\030\uffd4\031" + + "\uffd4\034\uffd4\055\uffd4\001\002\000\020\011\043\035\037" + + "\036\044\040\032\053\046\055\016\061\036\001\002\000" + + "\022\011\043\035\037\036\044\040\032\053\046\055\016" + + "\056\034\061\036\001\002\000\030\006\uffd9\020\uffd9\021" + + "\uffd9\022\uffd9\024\uffd9\025\uffd9\026\uffd9\030\uffd9\031\uffd9" + + "\034\uffd9\055\uffd9\001\002\000\030\006\uffd3\020\uffd3\021" + + "\uffd3\022\uffd3\024\uffd3\025\uffd3\026\uffd3\030\uffd3\031\uffd3" + + "\034\uffd3\055\uffd3\001\002\000\030\006\uffd8\020\uffd8\021" + + "\uffd8\022\uffd8\024\uffd8\025\uffd8\026\uffd8\030\uffd8\031\uffd8" + + "\034\uffd8\055\uffd8\001\002\000\030\006\uffd7\020\uffd7\021" + + "\uffd7\022\uffd7\024\uffd7\025\uffd7\026\uffd7\030\uffd7\031\uffd7" + + "\034\uffd7\055\uffd7\001\002\000\020\011\043\035\037\036" + + "\044\040\032\053\046\055\016\061\036\001\002\000\044" + + "\010\uffdf\012\uffdf\023\uffdf\027\uffdf\033\uffdf\037\uffdf\040" + + "\uffdf\041\uffdf\042\uffdf\043\uffdf\044\uffdf\045\uffdf\046\uffdf" + + "\047\uffdf\050\uffdf\051\uffdf\052\uffdf\001\002\000\004\010" + + "\103\001\002\000\044\010\uffe5\012\uffe5\023\uffe5\027\uffe5" + + "\033\uffe5\037\uffe5\040\uffe5\041\uffe5\042\uffe5\043\uffe5\044" + + "\uffe5\045\uffe5\046\uffe5\047\uffe5\050\uffe5\051\uffe5\052\uffe5" + + "\001\002\000\044\010\uffe4\012\uffe4\023\uffe4\027\uffe4\033" + + "\uffe4\037\uffe4\040\uffe4\041\uffe4\042\uffe4\043\uffe4\044\uffe4" + + "\045\uffe4\046\uffe4\047\uffe4\050\uffe4\051\uffe4\052\uffe4\001" + + "\002\000\044\010\uffe3\012\uffe3\023\uffe3\027\uffe3\033\uffe3" + + "\037\uffe3\040\uffe3\041\uffe3\042\uffe3\043\uffe3\044\uffe3\045" + + "\uffe3\046\uffe3\047\uffe3\050\uffe3\051\uffe3\052\uffe3\001\002" + + "\000\044\010\uffde\012\uffde\023\uffde\027\uffde\033\uffde\037" + + "\uffde\040\uffde\041\uffde\042\uffde\043\uffde\044\uffde\045\uffde" + + "\046\uffde\047\uffde\050\uffde\051\uffde\052\uffde\001\002\000" + + "\044\010\uffe0\012\uffe0\023\uffe0\027\uffe0\033\uffe0\037\uffe0" + + "\040\uffe0\041\uffe0\042\uffe0\043\uffe0\044\uffe0\045\uffe0\046" + + "\uffe0\047\uffe0\050\uffe0\051\uffe0\052\uffe0\001\002\000\044" + + "\010\uffdd\012\uffdd\023\uffdd\027\uffdd\033\uffdd\037\uffdd\040" + + "\uffdd\041\uffdd\042\uffdd\043\uffdd\044\uffdd\045\uffdd\046\uffdd" + + "\047\uffdd\050\uffdd\051\uffdd\052\uffdd\001\002\000\020\011" + + "\043\035\037\036\044\040\032\053\046\055\016\061\036" + + "\001\002\000\044\010\uffe2\012\uffe2\023\uffe2\027\uffe2\033" + + "\uffe2\037\uffe2\040\uffe2\041\uffe2\042\uffe2\043\uffe2\044\uffe2" + + "\045\uffe2\046\uffe2\047\uffe2\050\uffe2\051\uffe2\052\uffe2\001" + + "\002\000\034\010\100\037\055\040\050\041\060\042\053" + + "\043\061\044\057\045\056\046\052\047\063\050\054\051" + + "\051\052\062\001\002\000\020\011\043\035\037\036\044" + + "\040\032\053\046\055\016\061\036\001\002\000\044\010" + + "\uffe7\012\uffe7\023\uffe7\027\uffe7\033\uffe7\037\uffe7\040\uffe7" + + "\041\uffe7\042\uffe7\043\uffe7\044\uffe7\045\uffe7\046\uffe7\047" + + "\uffe7\050\uffe7\051\uffe7\052\uffe7\001\002\000\020\011\043" + + "\035\037\036\044\040\032\053\046\055\016\061\036\001" + + "\002\000\020\011\043\035\037\036\044\040\032\053\046" + + "\055\016\061\036\001\002\000\020\011\043\035\037\036" + + "\044\040\032\053\046\055\016\061\036\001\002\000\020" + + "\011\043\035\037\036\044\040\032\053\046\055\016\061" + + "\036\001\002\000\020\011\043\035\037\036\044\040\032" + + "\053\046\055\016\061\036\001\002\000\020\011\043\035" + + "\037\036\044\040\032\053\046\055\016\061\036\001\002" + + "\000\020\011\043\035\037\036\044\040\032\053\046\055" + + "\016\061\036\001\002\000\020\011\043\035\037\036\044" + + "\040\032\053\046\055\016\061\036\001\002\000\020\011" + + "\043\035\037\036\044\040\032\053\046\055\016\061\036" + + "\001\002\000\020\011\043\035\037\036\044\040\032\053" + + "\046\055\016\061\036\001\002\000\020\011\043\035\037" + + "\036\044\040\032\053\046\055\016\061\036\001\002\000" + + "\020\011\043\035\037\036\044\040\032\053\046\055\016" + + "\061\036\001\002\000\044\010\uffea\012\uffea\023\uffea\027" + + "\uffea\033\uffea\037\055\040\050\041\060\042\053\043\uffea" + + "\044\uffea\045\uffea\046\uffea\047\uffea\050\uffea\051\uffea\052" + + "\uffea\001\002\000\044\010\uffee\012\uffee\023\uffee\027\uffee" + + "\033\uffee\037\055\040\050\041\060\042\053\043\061\044" + + "\057\045\056\046\052\047\063\050\054\051\uffee\052\uffee" + + "\001\002\000\044\010\uffed\012\uffed\023\uffed\027\uffed\033" + + "\uffed\037\055\040\050\041\060\042\053\043\uffed\044\uffed" + + "\045\uffed\046\uffed\047\uffed\050\uffed\051\uffed\052\uffed\001" + + "\002\000\044\010\ufff1\012\ufff1\023\ufff1\027\ufff1\033\ufff1" + + "\037\ufff1\040\ufff1\041\ufff1\042\ufff1\043\ufff1\044\ufff1\045" + + "\ufff1\046\ufff1\047\ufff1\050\ufff1\051\ufff1\052\ufff1\001\002" + + "\000\044\010\uffec\012\uffec\023\uffec\027\uffec\033\uffec\037" + + "\055\040\050\041\060\042\053\043\uffec\044\uffec\045\uffec" + + "\046\uffec\047\uffec\050\uffec\051\uffec\052\uffec\001\002\000" + + "\044\010\uffeb\012\uffeb\023\uffeb\027\uffeb\033\uffeb\037\055" + + "\040\050\041\060\042\053\043\uffeb\044\uffeb\045\uffeb\046" + + "\uffeb\047\uffeb\050\uffeb\051\uffeb\052\uffeb\001\002\000\044" + + "\010\ufff3\012\ufff3\023\ufff3\027\ufff3\033\ufff3\037\ufff3\040" + + "\ufff3\041\060\042\053\043\ufff3\044\ufff3\045\ufff3\046\ufff3" + + "\047\ufff3\050\ufff3\051\ufff3\052\ufff3\001\002\000\044\010" + + "\uffe8\012\uffe8\023\uffe8\027\uffe8\033\uffe8\037\055\040\050" + + "\041\060\042\053\043\uffe8\044\uffe8\045\uffe8\046\uffe8\047" + + "\uffe8\050\uffe8\051\uffe8\052\uffe8\001\002\000\044\010\ufff0" + + "\012\ufff0\023\ufff0\027\ufff0\033\ufff0\037\ufff0\040\ufff0\041" + + "\ufff0\042\ufff0\043\ufff0\044\ufff0\045\ufff0\046\ufff0\047\ufff0" + + "\050\ufff0\051\ufff0\052\ufff0\001\002\000\044\010\uffe9\012" + + "\uffe9\023\uffe9\027\uffe9\033\uffe9\037\055\040\050\041\060" + + "\042\053\043\uffe9\044\uffe9\045\uffe9\046\uffe9\047\uffe9\050" + + "\uffe9\051\uffe9\052\uffe9\001\002\000\044\010\uffef\012\uffef" + + "\023\uffef\027\uffef\033\uffef\037\055\040\050\041\060\042" + + "\053\043\061\044\057\045\056\046\052\047\063\050\054" + + "\051\uffef\052\uffef\001\002\000\044\010\ufff2\012\ufff2\023" + + "\ufff2\027\ufff2\033\ufff2\037\ufff2\040\ufff2\041\060\042\053" + + "\043\ufff2\044\ufff2\045\ufff2\046\ufff2\047\ufff2\050\ufff2\051" + + "\ufff2\052\ufff2\001\002\000\030\006\uffd1\020\uffd1\021\uffd1" + + "\022\uffd1\024\uffd1\025\uffd1\026\uffd1\030\uffd1\031\uffd1\034" + + "\uffd1\055\uffd1\001\002\000\034\012\102\037\055\040\050" + + "\041\060\042\053\043\061\044\057\045\056\046\052\047" + + "\063\050\054\051\051\052\062\001\002\000\044\010\uffdc" + + "\012\uffdc\023\uffdc\027\uffdc\033\uffdc\037\uffdc\040\uffdc\041" + + "\uffdc\042\uffdc\043\uffdc\044\uffdc\045\uffdc\046\uffdc\047\uffdc" + + "\050\uffdc\051\uffdc\052\uffdc\001\002\000\030\006\uffd0\020" + + "\uffd0\021\uffd0\022\uffd0\024\uffd0\025\uffd0\026\uffd0\030\uffd0" + + "\031\uffd0\034\uffd0\055\uffd0\001\002\000\044\010\uffe6\012" + + "\uffe6\023\uffe6\027\uffe6\033\uffe6\037\uffe6\040\uffe6\041\uffe6" + + "\042\uffe6\043\uffe6\044\uffe6\045\uffe6\046\uffe6\047\uffe6\050" + + "\uffe6\051\uffe6\052\uffe6\001\002\000\034\023\106\037\055" + + "\040\050\041\060\042\053\043\061\044\057\045\056\046" + + "\052\047\063\050\054\051\051\052\062\001\002\000\022" + + "\020\uffda\021\uffda\022\uffda\024\uffda\025\uffda\026\uffda\031" + + "\uffda\055\uffda\001\002\000\006\024\110\025\111\001\002" + + "\000\020\020\uffda\021\uffda\022\uffda\025\uffda\026\uffda\031" + + "\uffda\055\uffda\001\002\000\030\006\uffcd\020\uffcd\021\uffcd" + + "\022\uffcd\024\uffcd\025\uffcd\026\uffcd\030\uffcd\031\uffcd\034" + + "\uffcd\055\uffcd\001\002\000\004\025\113\001\002\000\030" + + "\006\uffce\020\uffce\021\uffce\022\uffce\024\uffce\025\uffce\026" + + "\uffce\030\uffce\031\uffce\034\uffce\055\uffce\001\002\000\020" + + "\011\043\035\037\036\044\040\032\053\046\055\016\061" + + "\036\001\002\000\034\010\116\037\055\040\050\041\060" + + "\042\053\043\061\044\057\045\056\046\052\047\063\050" + + "\054\051\051\052\062\001\002\000\030\006\uffd2\020\uffd2" + + "\021\uffd2\022\uffd2\024\uffd2\025\uffd2\026\uffd2\030\uffd2\031" + + "\uffd2\034\uffd2\055\uffd2\001\002\000\004\032\120\001\002" + + "\000\020\011\043\035\037\036\044\040\032\053\046\055" + + "\016\061\036\001\002\000\034\033\122\037\055\040\050" + + "\041\060\042\053\043\061\044\057\045\056\046\052\047" + + "\063\050\054\051\051\052\062\001\002\000\020\011\043" + + "\035\037\036\044\040\032\053\046\055\016\061\036\001" + + "\002\000\034\027\124\037\055\040\050\041\060\042\053" + + "\043\061\044\057\045\056\046\052\047\063\050\054\051" + + "\051\052\062\001\002\000\020\020\uffda\021\uffda\022\uffda" + + "\026\uffda\031\uffda\034\uffda\055\uffda\001\002\000\004\034" + + "\126\001\002\000\030\006\uffcb\020\uffcb\021\uffcb\022\uffcb" + + "\024\uffcb\025\uffcb\026\uffcb\030\uffcb\031\uffcb\034\uffcb\055" + + "\uffcb\001\002\000\034\027\130\037\055\040\050\041\060" + + "\042\053\043\061\044\057\045\056\046\052\047\063\050" + + "\054\051\051\052\062\001\002\000\020\020\uffda\021\uffda" + + "\022\uffda\026\uffda\030\uffda\031\uffda\055\uffda\001\002\000" + + "\004\030\132\001\002\000\030\006\uffcc\020\uffcc\021\uffcc" + + "\022\uffcc\024\uffcc\025\uffcc\026\uffcc\030\uffcc\031\uffcc\034" + + "\uffcc\055\uffcc\001\002\000\004\010\134\001\002\000\030" + + "\006\uffcf\020\uffcf\021\uffcf\022\uffcf\024\uffcf\025\uffcf\026" + + "\uffcf\030\uffcf\031\uffcf\034\uffcf\055\uffcf\001\002\000\004" + + "\002\001\001\002\000\004\055\ufff6\001\002\000\012\005" + + "\ufffa\007\ufffa\057\ufffa\060\ufffa\001\002\000\012\005\ufffc" + + "\007\ufffc\057\ufffc\060\ufffc\001\002\000\006\057\136\060" + + "\144\001\002\000\012\005\ufffb\007\ufffb\057\ufffb\060\ufffb" + + "\001\002\000\004\055\145\001\002\000\004\055\ufff5\001" + + "\002\000\006\010\ufff8\013\ufff8\001\002\000\006\010\150" + + "\013\147\001\002\000\004\055\151\001\002\000\012\005" + + "\ufff9\007\ufff9\057\ufff9\060\ufff9\001\002\000\006\010\ufff7" + + "\013\ufff7\001\002\000\004\055\153\001\002\000\004\014" + + "\154\001\002\000\020\011\043\035\037\036\044\040\032" + + "\053\046\055\016\061\036\001\002\000\034\010\156\037" + + "\055\040\050\041\060\042\053\043\061\044\057\045\056" + + "\046\052\047\063\050\054\051\051\052\062\001\002\000" + + "\012\005\ufff4\007\ufff4\057\ufff4\060\ufff4\001\002\000\012" + + "\005\uffff\007\uffff\057\uffff\060\uffff\001\002\000\004\002" + + "\000\001\002" }); + + /** Access to parse-action table. */ + public short[][] action_table() {return _action_table;} + + /** <code>reduce_goto</code> table. */ + protected static final short[][] _reduce_table = + unpackFromStrings(new String[] { + "\000\156\000\006\002\003\003\005\001\001\000\002\001" + + "\001\000\002\001\001\000\006\004\007\007\006\001\001" + + "\000\012\010\137\011\141\012\136\031\142\001\001\000" + + "\002\001\001\000\006\005\011\006\012\001\001\000\002" + + "\001\001\000\022\014\021\016\026\017\022\020\017\021" + + "\030\022\020\023\025\024\027\001\001\000\002\001\001" + + "\000\016\013\126\014\034\015\041\025\037\026\040\027" + + "\032\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + + "\001\000\016\013\104\014\034\015\041\025\037\026\040" + + "\027\032\001\001\000\016\013\044\014\034\015\041\025" + + "\037\026\040\027\032\001\001\000\002\001\001\000\002" + + "\001\001\000\002\001\001\000\002\001\001\000\016\013" + + "\103\014\034\015\041\025\037\026\040\027\032\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\002\001\001\000\016\013\100\014\034\015" + + "\041\025\037\026\040\027\032\001\001\000\002\001\001" + + "\000\002\001\001\000\016\013\046\014\034\015\041\025" + + "\037\026\040\027\032\001\001\000\002\001\001\000\016" + + "\013\076\014\034\015\041\025\037\026\040\027\032\001" + + "\001\000\016\013\075\014\034\015\041\025\037\026\040" + + "\027\032\001\001\000\016\013\074\014\034\015\041\025" + + "\037\026\040\027\032\001\001\000\016\013\073\014\034" + + "\015\041\025\037\026\040\027\032\001\001\000\016\013" + + "\072\014\034\015\041\025\037\026\040\027\032\001\001" + + "\000\016\013\071\014\034\015\041\025\037\026\040\027" + + "\032\001\001\000\016\013\070\014\034\015\041\025\037" + + "\026\040\027\032\001\001\000\016\013\067\014\034\015" + + "\041\025\037\026\040\027\032\001\001\000\016\013\066" + + "\014\034\015\041\025\037\026\040\027\032\001\001\000" + + "\016\013\065\014\034\015\041\025\037\026\040\027\032" + + "\001\001\000\016\013\064\014\034\015\041\025\037\026" + + "\040\027\032\001\001\000\016\013\063\014\034\015\041" + + "\025\037\026\040\027\032\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\006\005\106\006\012\001\001\000\002\001" + + "\001\000\006\005\111\006\012\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\016\013\114\014" + + "\034\015\041\025\037\026\040\027\032\001\001\000\002" + + "\001\001\000\002\001\001\000\002\001\001\000\016\013" + + "\120\014\034\015\041\025\037\026\040\027\032\001\001" + + "\000\002\001\001\000\016\013\122\014\034\015\041\025" + + "\037\026\040\027\032\001\001\000\002\001\001\000\006" + + "\005\124\006\012\001\001\000\002\001\001\000\002\001" + + "\001\000\002\001\001\000\006\005\130\006\012\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\002\001\001\000\004\031\151\001\001\000" + + "\002\001\001\000\004\030\145\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\016\013\154\014\034\015\041\025\037\026" + + "\040\027\032\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001" }); + + /** Access to <code>reduce_goto</code> table. */ + public short[][] reduce_table() {return _reduce_table;} + + /** Instance of action encapsulation class. */ + protected CUP$parser$actions action_obj; + + /** Action encapsulation object initializer. */ + protected void init_actions() + { + action_obj = new CUP$parser$actions(this); + } + + /** Invoke a user supplied parse action. */ + public java_cup.runtime.Symbol do_action( + int act_num, + java_cup.runtime.lr_parser parser, + java.util.Stack stack, + int top) + throws java.lang.Exception + { + /* call code in generated class */ + return action_obj.CUP$parser$do_action(act_num, parser, stack, top); + } + + /** Indicates start state. */ + public int start_state() {return 0;} + /** Indicates start production. */ + public int start_production() {return 1;} + + /** <code>EOF</code> Symbol index. */ + public int EOF_sym() {return 0;} + + /** <code>error</code> Symbol index. */ + public int error_sym() {return 1;} + +} + +/** Cup generated class to encapsulate user supplied action code.*/ +class CUP$parser$actions { + + + + private final parser parser; + + /** Constructor */ + CUP$parser$actions(parser parser) { + this.parser = parser; + } + + /** Method with the actual generated action code. */ + public final java_cup.runtime.Symbol CUP$parser$do_action( + int CUP$parser$act_num, + java_cup.runtime.lr_parser CUP$parser$parser, + java.util.Stack CUP$parser$stack, + int CUP$parser$top) + throws java.lang.Exception + { + /* Symbol object for return from actions */ + java_cup.runtime.Symbol CUP$parser$result; + + /* select the action based on the action number */ + switch (CUP$parser$act_num) + { + /*. . . . . . . . . . . . . . . . . . . .*/ + case 54: // for_instr ::= FOR IDENT FROM expr TO expr DO body ENDFOR + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("for_instr",12, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-8)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 53: // while_instr ::= WHILE expr DO body ENDWHILE + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("while_instr",13, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 52: // cond_instr ::= IF expr THEN body ENDIF + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("cond_instr",14, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 51: // cond_instr ::= IF expr THEN body ELSE body ENDIF + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("cond_instr",14, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-6)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 50: // read_instr ::= READ IDENT SEMICOLON + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("read_instr",16, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 49: // write_instr ::= WRITE STRINGCONST SEMICOLON + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("write_instr",15, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 48: // write_instr ::= WRITE expr SEMICOLON + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("write_instr",15, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 47: // assign ::= access EQUAL expr SEMICOLON + { + Affectation RESULT =null; + int destleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left; + int destright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).right; + Expression dest = (Expression)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; + Object e = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int srcleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int srcright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + Expression src = (Expression)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + RESULT = new Affectation(dest, src, "", eleft, eright); + CUP$parser$result = parser.getSymbolFactory().newSymbol("assign",18, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 46: // instr ::= for_instr + { + Instruction RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("instr",17, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 45: // instr ::= while_instr + { + Instruction RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("instr",17, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 44: // instr ::= cond_instr + { + Instruction RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("instr",17, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 43: // instr ::= read_instr + { + Instruction RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("instr",17, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 42: // instr ::= write_instr + { + Instruction RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("instr",17, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 41: // instr ::= assign + { + Instruction RESULT =null; + int instleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int instright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + Affectation inst = (Affectation)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = inst; + CUP$parser$result = parser.getSymbolFactory().newSymbol("instr",17, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 40: // instr_lst ::= instr_lst instr + { + ArrayList<Instruction> RESULT =null; + int instructionListleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int instructionListright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + ArrayList<Instruction> instructionList = (ArrayList<Instruction>)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + int instructionleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int instructionright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + Instruction instruction = (Instruction)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + + ArrayList<Instruction> instructions = new ArrayList<Instruction>(instructionList); + instructions.add(instruction); + RESULT = instructions; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("instr_lst",4, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 39: // instr_lst ::= + { + ArrayList<Instruction> RESULT =null; + RESULT = new ArrayList(); + CUP$parser$result = parser.getSymbolFactory().newSymbol("instr_lst",4, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 38: // body ::= instr_lst + { + Bloc RESULT =null; + int instructionsleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int instructionsright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + ArrayList<Instruction> instructions = (ArrayList<Instruction>)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new Bloc(instructions, "", instructionsleft, instructionsright); + CUP$parser$result = parser.getSymbolFactory().newSymbol("body",3, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 37: // expr ::= OPENPARENT expr CLOSEPARENT + { + Expression RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("expr",9, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 36: // expr ::= operand + { + Expression RESULT =null; + int operandleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int operandright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + Expression operand = (Expression)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = operand; + CUP$parser$result = parser.getSymbolFactory().newSymbol("expr",9, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 35: // expr ::= op_una + { + Expression RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("expr",9, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 34: // expr ::= relation + { + Expression RESULT =null; + int expleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int expright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + Relation exp = (Relation)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = exp; + CUP$parser$result = parser.getSymbolFactory().newSymbol("expr",9, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 33: // expr ::= op_bin + { + Expression RESULT =null; + int expleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int expright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + Binaire exp = (Binaire)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = exp; + CUP$parser$result = parser.getSymbolFactory().newSymbol("expr",9, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 32: // access ::= IDENT + { + Expression RESULT =null; + int idleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int idright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String id = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new Idf(id, "", idleft, idright); + CUP$parser$result = parser.getSymbolFactory().newSymbol("access",10, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 31: // operand ::= FALSE + { + Expression RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("operand",11, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 30: // operand ::= TRUE + { + Expression RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("operand",11, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 29: // operand ::= INTEGERCONST + { + Expression RESULT =null; + int ibleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int ibright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + int ib = (int)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new Nombre(ib, "", ibleft, ibright); + CUP$parser$result = parser.getSymbolFactory().newSymbol("operand",11, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 28: // operand ::= access + { + Expression RESULT =null; + int accessleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int accessright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + Expression access = (Expression)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = access; + CUP$parser$result = parser.getSymbolFactory().newSymbol("operand",11, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 27: // op_una ::= MINUS expr + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("op_una",19, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 26: // op_una ::= NOT expr + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("op_una",19, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 25: // relation ::= expr SUPEQUAL expr + { + Relation RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("relation",21, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 24: // relation ::= expr INFEQUAL expr + { + Relation RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("relation",21, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 23: // relation ::= expr SUP expr + { + Relation RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("relation",21, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 22: // relation ::= expr INF expr + { + Relation RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("relation",21, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 21: // relation ::= expr DIFF expr + { + Relation RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("relation",21, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 20: // relation ::= expr EQUALS expr + { + Relation RESULT =null; + int aleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; + int aright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; + Expression a = (Expression)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int bleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int bright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + Expression b = (Expression)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new Egal(a, b, "", aleft, aright); + CUP$parser$result = parser.getSymbolFactory().newSymbol("relation",21, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 19: // op_bin ::= expr OR expr + { + Binaire RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("op_bin",20, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 18: // op_bin ::= expr AND expr + { + Binaire RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("op_bin",20, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 17: // op_bin ::= expr DIVIDE expr + { + Binaire RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("op_bin",20, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 16: // op_bin ::= expr TIMES expr + { + Binaire RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("op_bin",20, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 15: // op_bin ::= expr MINUS expr + { + Binaire RESULT =null; + int aleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; + int aright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; + Expression a = (Expression)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int bleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int bright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + Expression b = (Expression)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new Soustraction(a, b, "", aleft, aright); + CUP$parser$result = parser.getSymbolFactory().newSymbol("op_bin",20, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 14: // op_bin ::= expr PLUS expr + { + Binaire RESULT =null; + int aleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; + int aright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; + Expression a = (Expression)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int bleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int bright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + Expression b = (Expression)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new Addition(a, b, "", aleft, aright); + CUP$parser$result = parser.getSymbolFactory().newSymbol("op_bin",20, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 13: // declar_const ::= CONSTANT type IDENT EQUAL expr SEMICOLON + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("declar_const",8, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-5)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 12: // type ::= TBOOLEAN + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("type",23, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 11: // type ::= TINTEGER + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("type",23, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 10: // l_ident ::= l_ident COMMA IDENT + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("l_ident",22, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 9: // l_ident ::= IDENT + { + Object RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("l_ident",22, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 8: // declar_var ::= type l_ident SEMICOLON + { + ArrayList<Instruction> RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("declar_var",7, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 7: // declar ::= declar_const + { + ArrayList<Instruction> RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("declar",6, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 6: // declar ::= declar_var + { + ArrayList<Instruction> RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("declar",6, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 5: // declars ::= declars declar + { + ArrayList<Instruction> RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("declars",5, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 4: // declars ::= + { + ArrayList<Instruction> RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("declars",5, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 3: // declar_lst ::= declars + { + Bloc RESULT =null; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("declar_lst",2, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 2: // header ::= PRG IDENT + { + DeclarationProgramme RESULT =null; + int idleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left; + int idright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right; + String id = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new DeclarationProgramme(new Idf(id, "", idleft, idright), "", idleft, idright); + CUP$parser$result = parser.getSymbolFactory().newSymbol("header",1, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 1: // $START ::= program EOF + { + Object RESULT =null; + int start_valleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int start_valright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + DeclarationProgramme start_val = (DeclarationProgramme)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + RESULT = start_val; + CUP$parser$result = parser.getSymbolFactory().newSymbol("$START",0, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + /* ACCEPT */ + CUP$parser$parser.done_parsing(); + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 0: // program ::= header declar_lst STARTPRG body ENDPRG + { + DeclarationProgramme RESULT =null; + int programleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).left; + int programright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).right; + DeclarationProgramme program = (DeclarationProgramme)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-4)).value; + int declarationsleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left; + int declarationsright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).right; + Bloc declarations = (Bloc)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; + int instructionsleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int instructionsright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + Bloc instructions = (Bloc)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + + program.setInstructions(instructions); + + RESULT = program; + + CUP$parser$result = parser.getSymbolFactory().newSymbol("program",0, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT); + } + return CUP$parser$result; + + /* . . . . . .*/ + default: + throw new Exception( + "Invalid action number found in internal parse table"); + + } + } +} + diff --git a/sym.java b/sym.java new file mode 100644 index 0000000000000000000000000000000000000000..94a5a6eb0deff3f1f887c04bed0894d72c8477dd --- /dev/null +++ b/sym.java @@ -0,0 +1,59 @@ + +//---------------------------------------------------- +// The following code was generated by CUP v0.11a beta 20060608 +// Wed Nov 23 18:32:15 CET 2022 +//---------------------------------------------------- + +/** CUP generated class containing symbol constants. */ +public class sym { + /* terminals */ + public static final int DIVIDE = 32; + public static final int TBOOLEAN = 46; + public static final int EQUALS = 33; + public static final int UMINUS = 42; + public static final int CLOSEPARENT = 8; + public static final int PRG = 2; + public static final int FOR = 23; + public static final int MINUS = 30; + public static final int WRITE = 15; + public static final int STRINGCONST = 44; + public static final int NOT = 41; + public static final int AND = 39; + public static final int SEMICOLON = 6; + public static final int DOUBLEPOINTS = 11; + public static final int OR = 40; + public static final int INF = 35; + public static final int INTEGERCONST = 47; + public static final int COMMA = 9; + public static final int ENDPRG = 4; + public static final int ENDFOR = 26; + public static final int PLUS = 29; + public static final int IF = 16; + public static final int ENDWHILE = 22; + public static final int EOF = 0; + public static final int SUPEQUAL = 38; + public static final int STARTPRG = 3; + public static final int EQUAL = 10; + public static final int TRUE = 27; + public static final int error = 1; + public static final int INFEQUAL = 36; + public static final int IDENT = 43; + public static final int CONSTANT = 5; + public static final int FROM = 24; + public static final int TIMES = 31; + public static final int ENDIF = 19; + public static final int CLOSEBRACK = 13; + public static final int ELSE = 18; + public static final int TINTEGER = 45; + public static final int READ = 14; + public static final int TO = 25; + public static final int WHILE = 20; + public static final int OPENBRACK = 12; + public static final int SUP = 37; + public static final int THEN = 17; + public static final int DIFF = 34; + public static final int OPENPARENT = 7; + public static final int FALSE = 28; + public static final int DO = 21; +} +