mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-27 05:44:51 +00:00
Better float support.
Removed methodinfo parser.
This commit is contained in:
@@ -22,6 +22,9 @@ import java.util.List;
|
||||
import java.util.Stack;
|
||||
import java.math.BigInteger;
|
||||
import macromedia.asc.util.Decimal128;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.Matcher;
|
||||
import com.jpexs.decompiler.flash.abc.types.Float4;
|
||||
|
||||
%%
|
||||
|
||||
@@ -41,6 +44,8 @@ import macromedia.asc.util.Decimal128;
|
||||
|
||||
private boolean enableWhiteSpace = false;
|
||||
|
||||
private final Pattern float4Pattern = Pattern.compile("float4.*\\([\r\n \t\f]*(?<f1>[^\r\n \t\f]+)[\r\n \t\f]*,[\r\n \t\f]*(?<f2>[^\r\n \t\f]+)[\r\n \t\f]*,[\r\n \t\f]*(?<f3>[^\r\n \t\f]+)[\r\n \t\f]*,[\r\n \t\f]*(?<f4>[^\r\n \t\f]+)[\r\n \t\f]*\\)", Pattern.MULTILINE);
|
||||
|
||||
public ActionScriptLexer(String sourceCode){
|
||||
this(new StringReader(sourceCode));
|
||||
this.sourceCode = sourceCode;
|
||||
@@ -213,7 +218,11 @@ OctIntegerLiteral = 0+ [1-3]? {OctDigit}+
|
||||
OctDigit = [0-7]
|
||||
|
||||
/* floating point literals */
|
||||
DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [mdf]?
|
||||
DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [md]?
|
||||
|
||||
FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? f?
|
||||
|
||||
Float4Literal = float4 {WhiteSpace}* \( {WhiteSpace}* {FloatLiteral} {WhiteSpace}* , {WhiteSpace}* {FloatLiteral} {WhiteSpace}* , {WhiteSpace}* {FloatLiteral} {WhiteSpace}* , {WhiteSpace}* {FloatLiteral} {WhiteSpace}* \)
|
||||
|
||||
FLit1 = [0-9]+ \. [0-9]*
|
||||
FLit2 = \. [0-9]+
|
||||
@@ -417,7 +426,27 @@ RegExp = \/([^\r\n/]|\\\/)+\/[a-z]*
|
||||
}
|
||||
return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble(dval));
|
||||
}
|
||||
{FloatLiteral} {
|
||||
String fval = yytext();
|
||||
if (fval.endsWith("f")) {
|
||||
fval = fval.substring(0, fval.length() - 1);
|
||||
}
|
||||
return new ParsedSymbol(SymbolGroup.FLOAT, SymbolType.FLOAT, Float.parseFloat(fval));
|
||||
}
|
||||
|
||||
{Float4Literal} {
|
||||
Matcher f4Matcher = float4Pattern.matcher(yytext());
|
||||
f4Matcher.matches();
|
||||
float[] fvalues = new float[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
String fval = f4Matcher.group("f" + (i + 1));
|
||||
if (fval.endsWith("f")) {
|
||||
fval = fval.substring(0, fval.length() - 1);
|
||||
}
|
||||
fvalues[i] = Float.parseFloat(fval);
|
||||
}
|
||||
return new ParsedSymbol(SymbolGroup.FLOAT4, SymbolType.FLOAT4, new Float4(fvalues));
|
||||
}
|
||||
/* comments */
|
||||
{Comment} { yyline += count(yytext(),"\n"); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user