mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-08-02 15:12:14 +00:00
AS1/2: Editing obfuscated identifiers via new paragraph (§) syntax
This commit is contained in:
@@ -1,329 +1,352 @@
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License
|
||||
* at http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package jsyntaxpane.lexers;
|
||||
|
||||
|
||||
import jsyntaxpane.Token;
|
||||
import jsyntaxpane.TokenType;
|
||||
|
||||
%%
|
||||
|
||||
%public
|
||||
%class ActionScriptLexer
|
||||
%extends DefaultJFlexLexer
|
||||
%final
|
||||
%unicode
|
||||
%char
|
||||
%type Token
|
||||
|
||||
|
||||
%{
|
||||
/**
|
||||
* Create an empty lexer, yyrset will be called later to reset and assign
|
||||
* the reader
|
||||
*/
|
||||
public ActionScriptLexer() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yychar() {
|
||||
return yychar;
|
||||
}
|
||||
|
||||
private static final byte PARAN = 1;
|
||||
private static final byte BRACKET = 2;
|
||||
private static final byte CURLY = 3;
|
||||
|
||||
private static String xmlTagName="";
|
||||
|
||||
%}
|
||||
|
||||
/* main character classes */
|
||||
LineTerminator = \r|\n|\r\n
|
||||
InputCharacter = [^\r\n]
|
||||
|
||||
WhiteSpace = {LineTerminator} | [ \t\f]+
|
||||
|
||||
/* comments */
|
||||
Comment = {TraditionalComment} | {EndOfLineComment}
|
||||
|
||||
TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/"
|
||||
EndOfLineComment = "//" {InputCharacter}* {LineTerminator}?
|
||||
|
||||
|
||||
|
||||
/* identifiers */
|
||||
Identifier = [:jletter:][:jletterdigit:]*
|
||||
|
||||
IdentifierNs = {Identifier} ":" {Identifier}
|
||||
|
||||
TypeNameSpec = ".<" {Identifier} ">"
|
||||
|
||||
/* XML */
|
||||
LetterColon = [:jletter] | ":"
|
||||
XMLIdentifier = {Identifier} | {IdentifierNs}
|
||||
XMLAttribute = " "* {XMLIdentifier} " "* "=" " "* \" {InputCharacter}* \" " "*
|
||||
XMLBeginOneTag = "<" {XMLIdentifier} {XMLAttribute}* ">"
|
||||
XMLBeginTag = "<" {XMLIdentifier} " "
|
||||
XMLEndTag = "</" {XMLIdentifier} ">"
|
||||
|
||||
/* integer literals */
|
||||
DecIntegerLiteral = 0 | [1-9][0-9]*
|
||||
|
||||
HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8}
|
||||
HexDigit = [0-9a-fA-F]
|
||||
|
||||
OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15}
|
||||
OctDigit = [0-7]
|
||||
|
||||
/* floating point literals */
|
||||
DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}?
|
||||
|
||||
FLit1 = [0-9]+ \. [0-9]*
|
||||
FLit2 = \. [0-9]+
|
||||
FLit3 = [0-9]+
|
||||
Exponent = [eE] [+-]? [0-9]+
|
||||
|
||||
NewVector = "new" {WhiteSpace}* "<"
|
||||
|
||||
/* string and character literals */
|
||||
StringCharacter = [^\r\n\"\\]
|
||||
SingleCharacter = [^\r\n\'\\]
|
||||
|
||||
%state STRING, CHARLITERAL, XMLSTARTTAG, XML
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* keywords */
|
||||
"break" |
|
||||
"case" |
|
||||
"continue" |
|
||||
"default" |
|
||||
"do" |
|
||||
"while" |
|
||||
"else" |
|
||||
"for" |
|
||||
"each" |
|
||||
"in" |
|
||||
"if" |
|
||||
"label" |
|
||||
"return" |
|
||||
"super" |
|
||||
"switch" |
|
||||
"throw" |
|
||||
"try" |
|
||||
"catch" |
|
||||
"finally" |
|
||||
"while" |
|
||||
"with" |
|
||||
"dynamic" |
|
||||
"final" |
|
||||
"internal" |
|
||||
"native" |
|
||||
"override" |
|
||||
"private" |
|
||||
"protected" |
|
||||
"public" |
|
||||
"static" |
|
||||
"class" |
|
||||
"const" |
|
||||
"extends" |
|
||||
"function" |
|
||||
"get" |
|
||||
"implements" |
|
||||
"interface" |
|
||||
"namespace" |
|
||||
"package" |
|
||||
"set" |
|
||||
"var" |
|
||||
"import" |
|
||||
"include" |
|
||||
"use" |
|
||||
"false" |
|
||||
"null" |
|
||||
"this" |
|
||||
"true" { return token(TokenType.KEYWORD); }
|
||||
|
||||
|
||||
/* operators */
|
||||
|
||||
"(" { return token(TokenType.OPERATOR, PARAN); }
|
||||
")" { return token(TokenType.OPERATOR, -PARAN); }
|
||||
"{" { return token(TokenType.OPERATOR, CURLY); }
|
||||
"}" { return token(TokenType.OPERATOR, -CURLY); }
|
||||
"[" { return token(TokenType.OPERATOR, BRACKET); }
|
||||
"]" { return token(TokenType.OPERATOR, -BRACKET); }
|
||||
";" |
|
||||
"," |
|
||||
"..." |
|
||||
"." |
|
||||
"=" |
|
||||
">" |
|
||||
"<" |
|
||||
"!" |
|
||||
"~" |
|
||||
"?" |
|
||||
":" |
|
||||
"==" |
|
||||
"<=" |
|
||||
">=" |
|
||||
"!=" |
|
||||
"&&" |
|
||||
"||" |
|
||||
"++" |
|
||||
"--" |
|
||||
"+" |
|
||||
"-" |
|
||||
"*" |
|
||||
"/" |
|
||||
"&" |
|
||||
"|" |
|
||||
"^" |
|
||||
"%" |
|
||||
"<<" |
|
||||
">>" |
|
||||
">>>" |
|
||||
"+=" |
|
||||
"-=" |
|
||||
"*=" |
|
||||
"/=" |
|
||||
"&=" |
|
||||
"|=" |
|
||||
"^=" |
|
||||
"%=" |
|
||||
"<<=" |
|
||||
">>=" |
|
||||
">>>=" |
|
||||
"as" |
|
||||
"delete" |
|
||||
"instanceof" |
|
||||
"is" |
|
||||
"::" |
|
||||
"new" |
|
||||
"typeof" |
|
||||
"void" |
|
||||
{NewVector} |
|
||||
"@" { return token(TokenType.OPERATOR); }
|
||||
|
||||
/* string literal */
|
||||
\" {
|
||||
yybegin(STRING);
|
||||
tokenStart = yychar;
|
||||
tokenLength = 1;
|
||||
}
|
||||
|
||||
/* character literal */
|
||||
\' {
|
||||
yybegin(CHARLITERAL);
|
||||
tokenStart = yychar;
|
||||
tokenLength = 1;
|
||||
}
|
||||
|
||||
/* numeric literals */
|
||||
|
||||
{DecIntegerLiteral} |
|
||||
|
||||
{HexIntegerLiteral} |
|
||||
|
||||
{OctIntegerLiteral} |
|
||||
|
||||
{DoubleLiteral} |
|
||||
{DoubleLiteral}[dD] { return token(TokenType.NUMBER); }
|
||||
|
||||
// JavaDoc comments need a state so that we can highlight the @ controls
|
||||
|
||||
/* comments */
|
||||
{Comment} { return token(TokenType.COMMENT); }
|
||||
|
||||
/* whitespace */
|
||||
{WhiteSpace} { }
|
||||
{TypeNameSpec} { return token(TokenType.IDENTIFIER); }
|
||||
{XMLBeginOneTag} { yybegin(XML);
|
||||
tokenStart = yychar;
|
||||
tokenLength = yylength();
|
||||
String s=yytext();
|
||||
s=s.substring(1,s.length()-1);
|
||||
if(s.contains(" ")){
|
||||
s=s.substring(0,s.indexOf(" "));
|
||||
}
|
||||
xmlTagName = s;
|
||||
}
|
||||
/*{XMLBeginTag} { yybegin(XMLSTARTTAG);
|
||||
tokenStart = yychar;
|
||||
tokenLength = yylength();
|
||||
String s=yytext();
|
||||
xmlTagName = s.substring(1);
|
||||
}*/
|
||||
/* identifiers */
|
||||
{Identifier} { return token(TokenType.IDENTIFIER); }
|
||||
}
|
||||
|
||||
<XMLSTARTTAG> {
|
||||
{XMLAttribute} { tokenLength += yylength();}
|
||||
{WhiteSpace} { tokenLength += yylength(); }
|
||||
">" { yybegin(XML); tokenLength += yylength();}
|
||||
}
|
||||
<XML> {
|
||||
{XMLBeginOneTag} { tokenLength += yylength();}
|
||||
{XMLEndTag} { tokenLength += yylength();
|
||||
String endtagname=yytext();
|
||||
endtagname=endtagname.substring(2,endtagname.length()-1);
|
||||
if(endtagname.equals(xmlTagName)){
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.STRING, tokenStart, tokenLength);
|
||||
}
|
||||
}
|
||||
.|\n { tokenLength += yylength(); }
|
||||
}
|
||||
|
||||
<STRING> {
|
||||
\" {
|
||||
yybegin(YYINITIAL);
|
||||
// length also includes the trailing quote
|
||||
return token(TokenType.STRING, tokenStart, tokenLength + 1);
|
||||
}
|
||||
|
||||
{StringCharacter}+ { tokenLength += yylength(); }
|
||||
|
||||
\\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); }
|
||||
|
||||
/* escape sequences */
|
||||
|
||||
\\. { tokenLength += 2; }
|
||||
{LineTerminator} { yybegin(YYINITIAL); }
|
||||
}
|
||||
|
||||
<CHARLITERAL> {
|
||||
\' {
|
||||
yybegin(YYINITIAL);
|
||||
// length also includes the trailing quote
|
||||
return token(TokenType.STRING, tokenStart, tokenLength + 1);
|
||||
}
|
||||
|
||||
{SingleCharacter}+ { tokenLength += yylength(); }
|
||||
|
||||
/* escape sequences */
|
||||
|
||||
\\. { tokenLength += 2; }
|
||||
{LineTerminator} { yybegin(YYINITIAL); }
|
||||
}
|
||||
|
||||
/* error fallback */
|
||||
.|\n { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License
|
||||
* at http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package jsyntaxpane.lexers;
|
||||
|
||||
|
||||
import jsyntaxpane.Token;
|
||||
import jsyntaxpane.TokenType;
|
||||
|
||||
%%
|
||||
|
||||
%public
|
||||
%class ActionScriptLexer
|
||||
%extends DefaultJFlexLexer
|
||||
%final
|
||||
%unicode
|
||||
%char
|
||||
%type Token
|
||||
|
||||
|
||||
%{
|
||||
/**
|
||||
* Create an empty lexer, yyrset will be called later to reset and assign
|
||||
* the reader
|
||||
*/
|
||||
public ActionScriptLexer() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yychar() {
|
||||
return yychar;
|
||||
}
|
||||
|
||||
private static final byte PARAN = 1;
|
||||
private static final byte BRACKET = 2;
|
||||
private static final byte CURLY = 3;
|
||||
|
||||
private static String xmlTagName="";
|
||||
|
||||
%}
|
||||
|
||||
/* main character classes */
|
||||
LineTerminator = \r|\n|\r\n
|
||||
InputCharacter = [^\r\n]
|
||||
|
||||
WhiteSpace = {LineTerminator} | [ \t\f]+
|
||||
|
||||
/* comments */
|
||||
Comment = {TraditionalComment} | {EndOfLineComment}
|
||||
|
||||
TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/"
|
||||
EndOfLineComment = "//" {InputCharacter}* {LineTerminator}?
|
||||
|
||||
|
||||
|
||||
/* identifiers */
|
||||
Identifier = [:jletter:][:jletterdigit:]*
|
||||
|
||||
IdentifierNs = {Identifier} ":" {Identifier}
|
||||
|
||||
TypeNameSpec = ".<" {Identifier} ">"
|
||||
|
||||
/* XML */
|
||||
LetterColon = [:jletter] | ":"
|
||||
XMLIdentifier = {Identifier} | {IdentifierNs}
|
||||
XMLAttribute = " "* {XMLIdentifier} " "* "=" " "* \" {InputCharacter}* \" " "*
|
||||
XMLBeginOneTag = "<" {XMLIdentifier} {XMLAttribute}* ">"
|
||||
XMLBeginTag = "<" {XMLIdentifier} " "
|
||||
XMLEndTag = "</" {XMLIdentifier} ">"
|
||||
|
||||
/* integer literals */
|
||||
DecIntegerLiteral = 0 | [1-9][0-9]*
|
||||
|
||||
HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8}
|
||||
HexDigit = [0-9a-fA-F]
|
||||
|
||||
OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15}
|
||||
OctDigit = [0-7]
|
||||
|
||||
/* floating point literals */
|
||||
DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}?
|
||||
|
||||
FLit1 = [0-9]+ \. [0-9]*
|
||||
FLit2 = \. [0-9]+
|
||||
FLit3 = [0-9]+
|
||||
Exponent = [eE] [+-]? [0-9]+
|
||||
|
||||
NewVector = "new" {WhiteSpace}* "<"
|
||||
|
||||
/* string and character literals */
|
||||
StringCharacter = [^\r\n\"\\]
|
||||
SingleCharacter = [^\r\n\'\\]
|
||||
|
||||
OIdentifierCharacter = [^\r\n\u00A7\\]
|
||||
|
||||
%state STRING, CHARLITERAL, XMLSTARTTAG, XML, OIDENTIFIER
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* keywords */
|
||||
"break" |
|
||||
"case" |
|
||||
"continue" |
|
||||
"default" |
|
||||
"do" |
|
||||
"while" |
|
||||
"else" |
|
||||
"for" |
|
||||
"each" |
|
||||
"in" |
|
||||
"if" |
|
||||
"label" |
|
||||
"return" |
|
||||
"super" |
|
||||
"switch" |
|
||||
"throw" |
|
||||
"try" |
|
||||
"catch" |
|
||||
"finally" |
|
||||
"while" |
|
||||
"with" |
|
||||
"dynamic" |
|
||||
"final" |
|
||||
"internal" |
|
||||
"native" |
|
||||
"override" |
|
||||
"private" |
|
||||
"protected" |
|
||||
"public" |
|
||||
"static" |
|
||||
"class" |
|
||||
"const" |
|
||||
"extends" |
|
||||
"function" |
|
||||
"get" |
|
||||
"implements" |
|
||||
"interface" |
|
||||
"namespace" |
|
||||
"package" |
|
||||
"set" |
|
||||
"var" |
|
||||
"import" |
|
||||
"include" |
|
||||
"use" |
|
||||
"false" |
|
||||
"null" |
|
||||
"this" |
|
||||
"true" { return token(TokenType.KEYWORD); }
|
||||
|
||||
|
||||
/* operators */
|
||||
|
||||
"(" { return token(TokenType.OPERATOR, PARAN); }
|
||||
")" { return token(TokenType.OPERATOR, -PARAN); }
|
||||
"{" { return token(TokenType.OPERATOR, CURLY); }
|
||||
"}" { return token(TokenType.OPERATOR, -CURLY); }
|
||||
"[" { return token(TokenType.OPERATOR, BRACKET); }
|
||||
"]" { return token(TokenType.OPERATOR, -BRACKET); }
|
||||
";" |
|
||||
"," |
|
||||
"..." |
|
||||
"." |
|
||||
"=" |
|
||||
">" |
|
||||
"<" |
|
||||
"!" |
|
||||
"~" |
|
||||
"?" |
|
||||
":" |
|
||||
"==" |
|
||||
"<=" |
|
||||
">=" |
|
||||
"!=" |
|
||||
"&&" |
|
||||
"||" |
|
||||
"++" |
|
||||
"--" |
|
||||
"+" |
|
||||
"-" |
|
||||
"*" |
|
||||
"/" |
|
||||
"&" |
|
||||
"|" |
|
||||
"^" |
|
||||
"%" |
|
||||
"<<" |
|
||||
">>" |
|
||||
">>>" |
|
||||
"+=" |
|
||||
"-=" |
|
||||
"*=" |
|
||||
"/=" |
|
||||
"&=" |
|
||||
"|=" |
|
||||
"^=" |
|
||||
"%=" |
|
||||
"<<=" |
|
||||
">>=" |
|
||||
">>>=" |
|
||||
"as" |
|
||||
"delete" |
|
||||
"instanceof" |
|
||||
"is" |
|
||||
"::" |
|
||||
"new" |
|
||||
"typeof" |
|
||||
"void" |
|
||||
{NewVector} |
|
||||
"@" { return token(TokenType.OPERATOR); }
|
||||
|
||||
/* string literal */
|
||||
\" {
|
||||
yybegin(STRING);
|
||||
tokenStart = yychar;
|
||||
tokenLength = 1;
|
||||
}
|
||||
"\u00A7" {
|
||||
yybegin(OIDENTIFIER);
|
||||
tokenStart = yychar;
|
||||
tokenLength = 1;
|
||||
}
|
||||
|
||||
/* character literal */
|
||||
\' {
|
||||
yybegin(CHARLITERAL);
|
||||
tokenStart = yychar;
|
||||
tokenLength = 1;
|
||||
}
|
||||
|
||||
/* numeric literals */
|
||||
|
||||
{DecIntegerLiteral} |
|
||||
|
||||
{HexIntegerLiteral} |
|
||||
|
||||
{OctIntegerLiteral} |
|
||||
|
||||
{DoubleLiteral} |
|
||||
{DoubleLiteral}[dD] { return token(TokenType.NUMBER); }
|
||||
|
||||
// JavaDoc comments need a state so that we can highlight the @ controls
|
||||
|
||||
/* comments */
|
||||
{Comment} { return token(TokenType.COMMENT); }
|
||||
|
||||
/* whitespace */
|
||||
{WhiteSpace} { }
|
||||
{TypeNameSpec} { return token(TokenType.IDENTIFIER); }
|
||||
{XMLBeginOneTag} { yybegin(XML);
|
||||
tokenStart = yychar;
|
||||
tokenLength = yylength();
|
||||
String s=yytext();
|
||||
s=s.substring(1,s.length()-1);
|
||||
if(s.contains(" ")){
|
||||
s=s.substring(0,s.indexOf(" "));
|
||||
}
|
||||
xmlTagName = s;
|
||||
}
|
||||
/*{XMLBeginTag} { yybegin(XMLSTARTTAG);
|
||||
tokenStart = yychar;
|
||||
tokenLength = yylength();
|
||||
String s=yytext();
|
||||
xmlTagName = s.substring(1);
|
||||
}*/
|
||||
/* identifiers */
|
||||
{Identifier} { return token(TokenType.IDENTIFIER); }
|
||||
}
|
||||
|
||||
<XMLSTARTTAG> {
|
||||
{XMLAttribute} { tokenLength += yylength();}
|
||||
{WhiteSpace} { tokenLength += yylength(); }
|
||||
">" { yybegin(XML); tokenLength += yylength();}
|
||||
}
|
||||
<XML> {
|
||||
{XMLBeginOneTag} { tokenLength += yylength();}
|
||||
{XMLEndTag} { tokenLength += yylength();
|
||||
String endtagname=yytext();
|
||||
endtagname=endtagname.substring(2,endtagname.length()-1);
|
||||
if(endtagname.equals(xmlTagName)){
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.STRING, tokenStart, tokenLength);
|
||||
}
|
||||
}
|
||||
.|\n { tokenLength += yylength(); }
|
||||
}
|
||||
|
||||
<STRING> {
|
||||
\" {
|
||||
yybegin(YYINITIAL);
|
||||
// length also includes the trailing quote
|
||||
return token(TokenType.STRING, tokenStart, tokenLength + 1);
|
||||
}
|
||||
|
||||
{StringCharacter}+ { tokenLength += yylength(); }
|
||||
|
||||
\\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); }
|
||||
|
||||
/* escape sequences */
|
||||
|
||||
\\. { tokenLength += 2; }
|
||||
{LineTerminator} { yybegin(YYINITIAL); }
|
||||
}
|
||||
|
||||
<OIDENTIFIER> {
|
||||
"\u00A7" {
|
||||
yybegin(YYINITIAL);
|
||||
// length also includes the trailing quote
|
||||
return token(TokenType.REGEX, tokenStart, tokenLength + 1);
|
||||
}
|
||||
|
||||
{OIdentifierCharacter}+ { tokenLength += yylength(); }
|
||||
|
||||
|
||||
/* escape sequences */
|
||||
|
||||
\\. { tokenLength += 2; }
|
||||
{LineTerminator} { yybegin(YYINITIAL); }
|
||||
}
|
||||
|
||||
<CHARLITERAL> {
|
||||
\' {
|
||||
yybegin(YYINITIAL);
|
||||
// length also includes the trailing quote
|
||||
return token(TokenType.STRING, tokenStart, tokenLength + 1);
|
||||
}
|
||||
|
||||
{SingleCharacter}+ { tokenLength += yylength(); }
|
||||
|
||||
/* escape sequences */
|
||||
|
||||
\\. { tokenLength += 2; }
|
||||
{LineTerminator} { yybegin(YYINITIAL); }
|
||||
}
|
||||
|
||||
/* error fallback */
|
||||
.|\n { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user