Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9e7f396

Browse files
committed
Update bytecode syntax highlighting grammar
1 parent f0abafd commit 9e7f396

File tree

2 files changed

+516
-553
lines changed

2 files changed

+516
-553
lines changed

‎src/main/java/club/bytecode/the/jda/gui/fileviewer/BytecodeTokenizer.flex‎

Lines changed: 10 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
// COMPILE THIS FILE WITH GRAMMARKIT PLUGIN FOR INTELLIJ
2+
// (JFLEX 1.7.0)
3+
// OR ELSE IT WON'T FUCKING WORK
14
package club.bytecode.the.jda.gui.fileviewer;
25

36
import java.io.*;
47
import javax.swing.text.Segment;
58

69
import org.fife.ui.rsyntaxtextarea.*;
710

8-
911
/**
1012
* Scanner the JDA Bytecode.<p>
1113
*
@@ -64,7 +66,6 @@ import org.fife.ui.rsyntaxtextarea.*;
6466
public BytecodeTokenizer() {
6567
}
6668

67-
6869
/**
6970
* Adds the token specified to the current linked list of tokens.
7071
*
@@ -73,7 +74,7 @@ import org.fife.ui.rsyntaxtextarea.*;
7374
*/
7475
private void addHyperlinkToken(int start, int end, int tokenType) {
7576
int so = start + offsetShift;
76-
addToken(zzBuffer, start,end, tokenType, so, true);
77+
addToken(zzBuffer.toString().toCharArray(), start,end, tokenType, so, true);
7778
}
7879

7980

@@ -95,7 +96,7 @@ import org.fife.ui.rsyntaxtextarea.*;
9596
*/
9697
private void addToken(int start, int end, int tokenType) {
9798
int so = start + offsetShift;
98-
addToken(zzBuffer, start,end, tokenType, so, false);
99+
addToken(zzBuffer.toString().toCharArray(), start,end, tokenType, so, false);
99100
}
100101

101102

@@ -142,27 +143,26 @@ import org.fife.ui.rsyntaxtextarea.*;
142143
public Token getTokenList(Segment text, int initialTokenType, int startOffset) {
143144

144145
resetTokenList();
145-
this.offsetShift = -text.offset +startOffset;
146+
this.offsetShift = startOffset;
146147

147148
// Start off in the proper state.
148149
int state = Token.NULL;
149150
switch (initialTokenType) {
150151
case Token.COMMENT_MULTILINE:
151152
state = MLC;
152-
start = text.offset;
153+
start = 0;
153154
break;
154155
case Token.COMMENT_DOCUMENTATION:
155156
state = DOCCOMMENT;
156-
start = text.offset;
157+
start = 0;
157158
break;
158159
default:
159160
state = Token.NULL;
160161
}
161162

162163
s = text;
163164
try {
164-
yyreset(zzReader);
165-
yybegin(state);
165+
reset(text, 0, text.count, state);
166166
return yylex();
167167
} catch (IOException ioe) {
168168
ioe.printStackTrace();
@@ -172,51 +172,6 @@ import org.fife.ui.rsyntaxtextarea.*;
172172
}
173173

174174

175-
/**
176-
* Refills the input buffer.
177-
*
178-
* Note: this is the correct zzRefill. Delete the other one.
179-
*
180-
* @return <code>true</code> if EOF was reached, otherwise
181-
* <code>false</code>.
182-
*/
183-
private boolean zzRefill() {
184-
return zzCurrentPos>=s.offset+s.count;
185-
}
186-
187-
188-
/**
189-
* Resets the scanner to read from a new input stream.
190-
* Does not close the old reader.
191-
*
192-
* All internal variables are reset, the old input stream
193-
* <b>cannot</b> be reused (internal buffer is discarded and lost).
194-
* Lexical state is set to <tt>YY_INITIAL</tt>.
195-
*
196-
* Note: this is the correct yyreset. Delete the other one.
197-
*
198-
* @param reader the new input stream
199-
*/
200-
public final void yyreset(Reader reader) {
201-
// 's' has been updated.
202-
zzBuffer = s.array;
203-
/*
204-
* We replaced the line below with the two below it because zzRefill
205-
* no longer "refills" the buffer (since the way we do it, it's always
206-
* "full" the first time through, since it points to the segment's
207-
* array). So, we assign zzEndRead here.
208-
*/
209-
zzStartRead = zzEndRead = s.offset;
210-
zzStartRead = s.offset;
211-
zzEndRead = zzStartRead + s.count - 1;
212-
zzCurrentPos = zzMarkedPos = s.offset;
213-
zzLexicalState = YYINITIAL;
214-
zzReader = reader;
215-
zzAtBOL = true;
216-
zzAtEOF = false;
217-
}
218-
219-
220175
%}
221176

222177
Letter = ([A-Za-z])
@@ -346,6 +301,7 @@ URL = (((https?|f(tp|ile))"://"|"www.")({URLCharacters}{URLEndCharacter})?)
346301
"super" |
347302
"switch" |
348303
"synchronized" |
304+
"synthetic" |
349305
"this" |
350306
"throw" |
351307
"throws" |

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /