mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-07 21:05:05 +00:00
Fixed: #1159 Regexp syntax hilight when not a regexp (only division)
This commit is contained in:
@@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
|
||||
## [Unreleased]
|
||||
### Fixed
|
||||
- #1114 Script search results dialogs closing on swf close
|
||||
- #1159 Regexp syntax hilight when not a regexp (only division)
|
||||
|
||||
## [13.0.2] - 2021-02-10
|
||||
### Changed
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -16,7 +16,7 @@
|
||||
</define>
|
||||
<define append="true">
|
||||
<name>CONFIG::timeStamp</name>
|
||||
<value>'10.02.2021'</value>
|
||||
<value>'11.02.2021'</value>
|
||||
</define>
|
||||
<define append="true">
|
||||
<name>CONFIG::air</name>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
</define>
|
||||
<define append="true">
|
||||
<name>CONFIG::timeStamp</name>
|
||||
<value>'10.02.2021'</value>
|
||||
<value>'11.02.2021'</value>
|
||||
</define>
|
||||
<define append="true">
|
||||
<name>CONFIG::air</name>
|
||||
|
||||
@@ -102,6 +102,7 @@ package
|
||||
TestThisOutsideClass;
|
||||
TestImports;
|
||||
TestInitializer;
|
||||
TestRegexpHilight;
|
||||
|
||||
public function Main()
|
||||
{
|
||||
|
||||
23
libsrc/ffdec_lib/testdata/as3_new/src/tests_classes/TestRegexpHilight.as
vendored
Normal file
23
libsrc/ffdec_lib/testdata/as3_new/src/tests_classes/TestRegexpHilight.as
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
package tests_classes
|
||||
{
|
||||
/**
|
||||
* ...
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class TestRegexpHilight
|
||||
{
|
||||
|
||||
public function run():void
|
||||
{
|
||||
var myregexp:RegExp = /[a-z0-9_]+/;
|
||||
var a:Number = 10;
|
||||
var b:Number = 20;
|
||||
var notaregexp:Number = a / b + b / a;
|
||||
|
||||
trace(myregexp);
|
||||
trace(notaregexp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -81,7 +81,10 @@ public class ScriptAction extends DefaultSyntaxAction {
|
||||
*
|
||||
* @param url
|
||||
*/
|
||||
public void getScriptFromURL(String url) {
|
||||
public void getScriptFromURL(String url) {
|
||||
if (engine == null) {
|
||||
return;
|
||||
}
|
||||
InputStream is = JarServiceProvider.findResource(url, this.getClass().getClassLoader());
|
||||
if (is != null) {
|
||||
Reader reader = new InputStreamReader(is);
|
||||
|
||||
@@ -17,7 +17,12 @@ package jsyntaxpane.lexers;
|
||||
|
||||
import jsyntaxpane.Token;
|
||||
import jsyntaxpane.TokenType;
|
||||
|
||||
import javax.swing.text.Segment;
|
||||
import java.io.CharArrayReader;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.List;
|
||||
%%
|
||||
|
||||
%public
|
||||
@@ -31,7 +36,7 @@ import jsyntaxpane.TokenType;
|
||||
|
||||
%{
|
||||
/**
|
||||
* Create an empty lexer, yyrset will be called later to reset and assign
|
||||
* Create an empty lexer, yyreset will be called later to reset and assign
|
||||
* the reader
|
||||
*/
|
||||
public ActionScriptLexer() {
|
||||
@@ -49,6 +54,26 @@ import jsyntaxpane.TokenType;
|
||||
|
||||
private static String xmlTagName="";
|
||||
|
||||
private Token prevToken = null;
|
||||
|
||||
@Override
|
||||
public void parse(Segment segment, int ofst, List<Token> tokens) {
|
||||
try {
|
||||
CharArrayReader reader = new CharArrayReader(segment.array, segment.offset, segment.count);
|
||||
yyreset(reader);
|
||||
this.offset = ofst;
|
||||
prevToken = null;
|
||||
Token t = yylex();
|
||||
prevToken = t;
|
||||
for (; t != null; t = yylex()) {
|
||||
prevToken = t;
|
||||
tokens.add(t);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(DefaultJFlexLexer.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
/* main character classes */
|
||||
@@ -177,11 +202,20 @@ RegExp = \/([^\r\n/]|\\\/)+\/[a-z]*
|
||||
"true" { return token(TokenType.KEYWORD); }
|
||||
|
||||
|
||||
{RegExp} { return token(TokenType.REGEX); }
|
||||
{RegExp} {
|
||||
if (prevToken == null || prevToken.type == TokenType.OPERATOR) {
|
||||
return token(TokenType.REGEX);
|
||||
} else {
|
||||
int ch = yychar;
|
||||
yypushback(yylength()-1);
|
||||
// divide "/" operator
|
||||
return token(TokenType.OPERATOR,ch,1);
|
||||
}
|
||||
}
|
||||
|
||||
/* operators */
|
||||
|
||||
"(" { return token(TokenType.OPERATOR, PARAN); }
|
||||
"(" { return token(TokenType.OPERATOR, PARAN); }
|
||||
")" { return token(TokenType.OPERATOR, -PARAN); }
|
||||
"{" { return token(TokenType.OPERATOR, CURLY); }
|
||||
"}" { return token(TokenType.OPERATOR, -CURLY); }
|
||||
|
||||
Reference in New Issue
Block a user