pushedBack = new Stack<>();
-
- public int yyline() {
- return yyline + 1;
- }
-
- public void pushback(ParsedSymbol symb) {
- pushedBack.push(symb);
- last = null;
- }
-
- ParsedSymbol last;
-
- public ParsedSymbol lex() throws java.io.IOException, Amf3ParseException {
- ParsedSymbol ret = null;
- if (!pushedBack.isEmpty()) {
- ret = last = pushedBack.pop();
- } else {
- ret = last = yylex();
- }
- return ret;
- }
-
- /**
- * Creates a new scanner
- *
- * @param in the java.io.Reader to read input from.
- */
- public Amf3Lexer(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 < 2856) {
- int count = packed.charAt(i++);
- char value = packed.charAt(i++);
- do {
- map[j++] = value;
- } while (--count > 0);
- }
- return map;
- }
-
- /**
- * Refills the input buffer.
- *
- * @return false, iff there was new input.
- * @throws 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 totalRead = 0;
- while (totalRead < requested) {
- int numRead = zzReader.read(zzBuffer, zzEndRead + totalRead, requested - totalRead);
- if (numRead == -1) {
- break;
- }
- totalRead += numRead;
- }
-
- if (totalRead > 0) {
- zzEndRead += totalRead;
- if (totalRead == requested) {
- /* possibly more input available */
- if (Character.isHighSurrogate(zzBuffer[zzEndRead - 1])) {
- --zzEndRead;
- zzFinalHighSurrogate = 1;
- }
- }
- return false;
- }
-
- // totalRead = 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
- * cannot be reused (internal buffer is discarded and lost). Lexical
- * state is set to ZZ_INITIAL.
- *
- * 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 pos 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;
- }
-
- /**
- * 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
- * @throws java.io.IOException if any I/O-Error occurs
- */
- public ParsedSymbol yylex() throws java.io.IOException, Amf3ParseException {
- 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;
-
- yychar += zzMarkedPosL - zzStartRead;
-
- 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;
-
- switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
- case 1: {
- }
- case 36:
- break;
- case 2: {
- yyline++;
- }
- case 37:
- break;
- case 3: {
- /*ignore*/
- }
- case 38:
- break;
- case 4: {
- return new ParsedSymbol(SymbolGroup.IDENTIFIER, SymbolType.IDENTIFIER, yytext());
- }
- case 39:
- break;
- case 5: {
- return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong((yytext())));
- }
- case 40:
- break;
- case 6: {
- return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.CURLY_OPEN, yytext());
- }
- case 41:
- break;
- case 7: {
- return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.CURLY_CLOSE, yytext());
- }
- case 42:
- break;
- case 8: {
- return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.BRACKET_OPEN, yytext());
- }
- case 43:
- break;
- case 9: {
- return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.BRACKET_CLOSE, yytext());
- }
- case 44:
- break;
- case 10: {
- return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.COMMA, yytext());
- }
- case 45:
- break;
- case 11: {
- return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.COLON, yytext());
- }
- case 46:
- break;
- case 12: {
- string.setLength(0);
- yybegin(STRING);
- }
- case 47:
- break;
- case 13: {
- string.append(yytext());
- }
- case 48:
- break;
- case 14: {
- yybegin(YYINITIAL);
- yyline++;
- }
- case 49:
- break;
- case 15: {
- yybegin(YYINITIAL);
- // length also includes the trailing quote
- return new ParsedSymbol(SymbolGroup.STRING, SymbolType.STRING, string.toString());
- }
- case 50:
- break;
- case 16: {
- return new ParsedSymbol(SymbolGroup.IDENTIFIER, SymbolType.REFERENCE, yytext().substring(1));
- }
- case 51:
- break;
- case 17: {
- return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong(yytext(), 8));
- }
- case 52:
- break;
- case 18: {
- return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble((yytext())));
- }
- case 53:
- break;
- case 19: {
- string.append('\\');
- /*illegal escape sequence*/
- }
- case 54:
- break;
- case 20: {
- string.append('\\');
- }
- case 55:
- break;
- case 21: {
- string.append('\n');
- }
- case 56:
- break;
- case 22: {
- string.append('\f');
- }
- case 57:
- break;
- case 23: {
- string.append('\t');
- }
- case 58:
- break;
- case 24: {
- string.append('\r');
- }
- case 59:
- break;
- case 25: {
- string.append('\"');
- }
- case 60:
- break;
- case 26: {
- string.append('\b');
- }
- case 61:
- break;
- case 27: {
- string.append('\'');
- }
- case 62:
- break;
- case 28: {
- return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong(yytext().substring(2), 16));
- }
- case 63:
- break;
- case 29: {
- return new ParsedSymbol(SymbolGroup.GLOBALCONST, SymbolType.NULL, yytext());
- }
- case 64:
- break;
- case 30: {
- return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.TRUE, yytext());
- }
- case 65:
- break;
- case 31: {
- char val = (char) Integer.parseInt(yytext().substring(1), 8);
- string.append(val);
- }
- case 66:
- break;
- case 32: {
- char val = (char) Integer.parseInt(yytext().substring(2), 16);
- string.append(val);
- }
- case 67:
- break;
- case 33: {
- return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.FALSE, yytext());
- }
- case 68:
- break;
- case 34: {
- return new ParsedSymbol(SymbolGroup.UNKNOWN, SymbolType.UNKNOWN, yytext());
- }
- case 69:
- break;
- case 35: {
- return new ParsedSymbol(SymbolGroup.GLOBALCONST, SymbolType.UNDEFINED, yytext());
- }
- case 70:
- break;
- default:
- if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
- zzAtEOF = true;
- {
- return new ParsedSymbol(SymbolGroup.EOF, SymbolType.EOF, null);
- }
- } else {
- zzScanError(ZZ_NO_MATCH);
- }
- }
- }
- }
-
-}
diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/amf/package-info.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/amf/package-info.java
new file mode 100644
index 000000000..964d82045
--- /dev/null
+++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/amf/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * AMF lexers and importers.
+ */
+package com.jpexs.decompiler.flash.importers.amf;
diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/sol/SolFile.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/sol/SolFile.java
index 730909648..5d6320a8c 100644
--- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/sol/SolFile.java
+++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/sol/SolFile.java
@@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.exporters.amf.amf0.Amf0Exporter;
import com.jpexs.decompiler.flash.exporters.amf.amf3.Amf3Exporter;
import com.jpexs.decompiler.flash.importers.amf.amf0.Amf0Importer;
import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3Importer;
-import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3ParseException;
+import com.jpexs.decompiler.flash.importers.amf.AmfParseException;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.EOFException;
@@ -199,7 +199,7 @@ public class SolFile {
Map imported = importer.stringToAmfMap(amf0string);
String amf0stringNew = Amf0Exporter.amfMapToString(imported, 0, "\r\n");
System.err.println("same0 = " + amf0stringNew.equals(amf0string));
- } catch (Amf3ParseException ex) {
+ } catch (AmfParseException ex) {
ex.printStackTrace();
}
}
@@ -216,7 +216,7 @@ public class SolFile {
Map imported = importer.stringToAmfMap(amf3string);
String amf3stringNew = Amf3Exporter.amfMapToString(imported, " ", "\r\n", 0);;
System.err.println("same3 = " + amf3stringNew.equals(amf3string));
- } catch (Amf3ParseException ex) {
+ } catch (AmfParseException ex) {
ex.printStackTrace();
}
}
diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/importers/amf/amf3/parser/Amf3ImporterTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/importers/amf/amf3/parser/Amf3ImporterTest.java
index 06440676c..f03f31202 100644
--- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/importers/amf/amf3/parser/Amf3ImporterTest.java
+++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/importers/amf/amf3/parser/Amf3ImporterTest.java
@@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.amf.amf3.NoSerializerExistsException;
import com.jpexs.decompiler.flash.amf.amf3.ObjectTypeSerializeHandler;
import com.jpexs.decompiler.flash.exporters.amf.amf3.Amf3Exporter;
import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3Importer;
-import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3ParseException;
+import com.jpexs.decompiler.flash.importers.amf.AmfParseException;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.MemoryInputStream;
import java.io.File;
@@ -73,7 +73,7 @@ public class Amf3ImporterTest {
}
@Test(dataProvider = "files")
- public void testRecompile(String fileName) throws IOException, NoSerializerExistsException, Amf3ParseException {
+ public void testRecompile(String fileName) throws IOException, NoSerializerExistsException, AmfParseException {
String originalFile = "testdata/amf3/generated/" + fileName;
diff --git a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java
index e2cd38756..498b8857c 100644
--- a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java
+++ b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java
@@ -132,7 +132,7 @@ import com.jpexs.decompiler.flash.importers.SwfXmlImporter;
import com.jpexs.decompiler.flash.importers.SymbolClassImporter;
import com.jpexs.decompiler.flash.importers.TextImporter;
import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3Importer;
-import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3ParseException;
+import com.jpexs.decompiler.flash.importers.amf.AmfParseException;
import com.jpexs.decompiler.flash.importers.svg.SvgImporter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag;
@@ -1304,7 +1304,7 @@ public class CommandLineArgumentParser {
amfValue = ais.readValue("val");
break;
}
- } catch (IOException | Amf3ParseException | NoSerializerExistsException ex) {
+ } catch (IOException | AmfParseException | NoSerializerExistsException ex) {
System.err.println("Error parsing input value: " + ex.getMessage());
System.exit(1);
return;
diff --git a/src/com/jpexs/decompiler/flash/gui/generictageditors/Amf3ValueEditor.java b/src/com/jpexs/decompiler/flash/gui/generictageditors/Amf3ValueEditor.java
index 196b6d065..8004d4161 100644
--- a/src/com/jpexs/decompiler/flash/gui/generictageditors/Amf3ValueEditor.java
+++ b/src/com/jpexs/decompiler/flash/gui/generictageditors/Amf3ValueEditor.java
@@ -24,7 +24,7 @@ import com.jpexs.decompiler.flash.gui.View;
import com.jpexs.decompiler.flash.gui.ViewMessages;
import com.jpexs.decompiler.flash.gui.editor.LineMarkedEditorPane;
import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3Importer;
-import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3ParseException;
+import com.jpexs.decompiler.flash.importers.amf.AmfParseException;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.ReflectionTools;
import java.awt.BorderLayout;
@@ -212,10 +212,10 @@ public class Amf3ValueEditor extends JPanel implements GenericTagEditor, FullSiz
if (!textVal.trim().isEmpty()) {
importer.stringToAmf(textVal);
}
- } catch (IOException | Amf3ParseException ex) {
+ } catch (IOException | AmfParseException ex) {
- if (ex instanceof Amf3ParseException) {
- Amf3ParseException ape = (Amf3ParseException) ex;
+ if (ex instanceof AmfParseException) {
+ AmfParseException ape = (AmfParseException) ex;
if (ape.line > 0) {
editor.gotoLine((int) ape.line);
}
@@ -240,7 +240,7 @@ public class Amf3ValueEditor extends JPanel implements GenericTagEditor, FullSiz
String textVal = editor.getText();
try {
return textVal.trim().isEmpty() ? null : new Amf3Value(importer.stringToAmf(textVal));
- } catch (IOException | Amf3ParseException ex) {
+ } catch (IOException | AmfParseException ex) {
return value;
}
}
diff --git a/src/com/jpexs/decompiler/flash/gui/soleditor/SolEditorFrame.java b/src/com/jpexs/decompiler/flash/gui/soleditor/SolEditorFrame.java
index 199224d1e..d0c08f8fb 100644
--- a/src/com/jpexs/decompiler/flash/gui/soleditor/SolEditorFrame.java
+++ b/src/com/jpexs/decompiler/flash/gui/soleditor/SolEditorFrame.java
@@ -27,7 +27,7 @@ import com.jpexs.decompiler.flash.gui.ViewMessages;
import com.jpexs.decompiler.flash.gui.editor.LineMarkedEditorPane;
import com.jpexs.decompiler.flash.importers.amf.amf0.Amf0Importer;
import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3Importer;
-import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3ParseException;
+import com.jpexs.decompiler.flash.importers.amf.AmfParseException;
import com.jpexs.decompiler.flash.sol.SolFile;
import com.jpexs.helpers.Helper;
import java.awt.BorderLayout;
@@ -269,7 +269,7 @@ public class SolEditorFrame extends AppFrame {
amfVersionComboBox.setVisible(false);
amfVersionLabel.setVisible(true);
ViewMessages.showMessageDialog(this, translate("info.saved"), AppStrings.translate("message.info"), JOptionPane.INFORMATION_MESSAGE);
- } catch (Amf3ParseException ex) {
+ } catch (AmfParseException ex) {
editor.gotoLine((int) ex.line);
editor.markError();
ViewMessages.showMessageDialog(this, translate("error.parse").replace("%reason%", ex.text).replace("%line%", "" + ex.line), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);