From 52adc8851062776be8f18978d289090b0dd3078e Mon Sep 17 00:00:00 2001 From: Corey-Dean Arthur <1339555+CoreyD97@users.noreply.github.com> Date: Wed, 31 Mar 2021 16:23:56 +0100 Subject: [PATCH 1/8] Panel listener only executes convert once --- src/main/java/burp/Convertors.java | 14 +++++--- src/main/java/burp/ui/HackvertorPanel.java | 38 ++++++++++++++++------ 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/main/java/burp/Convertors.java b/src/main/java/burp/Convertors.java index 6886e3d..c7cc5b6 100644 --- a/src/main/java/burp/Convertors.java +++ b/src/main/java/burp/Convertors.java @@ -518,6 +518,13 @@ public static String callTag(HashMap variableMap, JSONArray cust return loop_letters_upper(variableMap, customTags, output, getString(arguments, 0)); case "loop_numbers": return loop_letters_numbers(variableMap, customTags, output, getString(arguments, 0)); + case "sleep": + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + return ""; } } @@ -2247,13 +2254,10 @@ static String substring(String str, int start, int end) { } static String repeat(String str, int amount) { - String output = ""; if (amount > 0 && amount < 10000) { - for (int i = 0; i < amount; i++) { - output += str; - } + return str.repeat(amount); } - return output; + return ""; } static String split_join(String str, String splitChar, String joinChar) { diff --git a/src/main/java/burp/ui/HackvertorPanel.java b/src/main/java/burp/ui/HackvertorPanel.java index c126b95..eb223a2 100644 --- a/src/main/java/burp/ui/HackvertorPanel.java +++ b/src/main/java/burp/ui/HackvertorPanel.java @@ -11,6 +11,7 @@ import javax.swing.*; import javax.swing.event.*; +import javax.swing.text.BadLocationException; import javax.swing.text.Document; import javax.swing.undo.CannotRedoException; import javax.swing.undo.CannotUndoException; @@ -22,6 +23,7 @@ import java.io.IOException; import java.util.HashMap; import java.util.LinkedList; +import java.util.concurrent.*; import java.util.stream.Collectors; import static burp.BurpExtender.*; @@ -135,26 +137,42 @@ public void actionPerformed(ActionEvent evt) { } final JTextArea outputArea = new JTextArea(); outputArea.setFont(new Font("Courier New", Font.PLAIN, 12)); + DocumentListener documentListener = new DocumentListener() { + LinkedBlockingQueue queue = new LinkedBlockingQueue<>(1); + ExecutorService executorService = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, + queue, new ThreadPoolExecutor.DiscardOldestPolicy()); + + public void scheduleUpdate(){ + executorService.submit(() -> { + String output = hackvertor.convert(inputArea.getText()); + try { + outputArea.getDocument().remove(0, outputArea.getDocument().getLength()); + outputArea.getDocument().insertString(0, output, null); + } catch (BadLocationException e) { + e.printStackTrace(); + } + outputArea.setCaretPosition(0); + }); + } + + public void changedUpdate(DocumentEvent documentEvent) { - updateLen(documentEvent); - outputArea.setText(hackvertor.convert(inputArea.getText())); - outputArea.setCaretPosition(0); + updateLen(); + scheduleUpdate(); } public void insertUpdate(DocumentEvent documentEvent) { - updateLen(documentEvent); - outputArea.setText(hackvertor.convert(inputArea.getText())); - outputArea.setCaretPosition(0); + updateLen(); + scheduleUpdate(); } public void removeUpdate(DocumentEvent documentEvent) { - updateLen(documentEvent); - outputArea.setText(hackvertor.convert(inputArea.getText())); - outputArea.setCaretPosition(0); + updateLen(); + scheduleUpdate(); } - private void updateLen(DocumentEvent documentEvent) { + private void updateLen() { int len = inputArea.getText().length(); int realLen = calculateRealLen(inputArea.getText()); inputLenLabel.setText("" + len); From 1808730c51e39781de07f30caf57a6e0ce0a9b38 Mon Sep 17 00:00:00 2001 From: Corey <1339555+CoreyD97@users.noreply.github.com> Date: Thu, 11 May 2023 10:55:22 +0100 Subject: [PATCH 2/8] Update Java version. --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index fde3ffe..478666f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ apply plugin: 'java' -targetCompatibility = 1.8 -sourceCompatibility = 1.8 +targetCompatibility = JavaVersion.VERSION_17 +sourceCompatibility = JavaVersion.VERSION_17 compileJava.options.encoding = 'UTF-8' compileTestJava.options.encoding = 'UTF-8' From d0174c3af172254aa25469f95a0b3940ab67eec1 Mon Sep 17 00:00:00 2001 From: Corey <1339555+CoreyD97@users.noreply.github.com> Date: Thu, 11 May 2023 10:56:11 +0100 Subject: [PATCH 3/8] Small improvements. Use scheduler to prevent lag when converting large documents. --- hackvertor.iml | 37 +--------------- src/main/java/burp/Convertors.java | 50 +++++++++++++--------- src/main/java/burp/ui/HackvertorInput.java | 2 +- src/main/java/burp/ui/HackvertorPanel.java | 5 +-- 4 files changed, 32 insertions(+), 62 deletions(-) diff --git a/hackvertor.iml b/hackvertor.iml index ec337e0..0aa8195 100644 --- a/hackvertor.iml +++ b/hackvertor.iml @@ -1,43 +1,8 @@ - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/java/burp/Convertors.java b/src/main/java/burp/Convertors.java index ac074c3..576108a 100644 --- a/src/main/java/burp/Convertors.java +++ b/src/main/java/burp/Convertors.java @@ -135,7 +135,7 @@ public static String callTag(HashMap variableMap, JSONArray cust tagCount.put(tag, count + 1); } for(int i=0;i variables, JSONArray customTags, String input){ + public static String strictConvert(HashMap variables, JSONArray customTags, String input, Hackvertor hackvertor){ Queue tagElements; try { tagElements = HackvertorParser.parse(input); - return convert(variables, customTags, "", new Stack<>(), tagElements); + return strictConvert(variables, customTags, "", new Stack<>(), tagElements, hackvertor); }catch (Exception e){ StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); @@ -655,7 +655,7 @@ public static String weakConvert(HashMap variables, JSONArray cu Queue tagElements; try { tagElements = HackvertorParser.parse(input); - tagElements = weakConvertProcessSetTags(variables, customTags, tagElements); + tagElements = weakConvertPreProcessSetTags(variables, customTags, tagElements); return weakConvert(variables, customTags, new Stack<>(), tagElements, hackvertor); }catch (Exception e){ StringWriter sw = new StringWriter(); @@ -666,7 +666,7 @@ public static String weakConvert(HashMap variables, JSONArray cu /** * Recursive conversion, ensuring tags are properly matched. - * Does not treat mismatched tags as text. + * Does not treat mismatched tags as text. Will throw an error instead. * @param variables * @param customTags * @param textBuffer @@ -675,11 +675,11 @@ public static String weakConvert(HashMap variables, JSONArray cu * @return * @throws ParseException */ - private static String convert(HashMap variables, - JSONArray customTags, - String textBuffer, - Stack stack, - Queue elements) throws ParseException{ + private static String strictConvert(HashMap variables, + JSONArray customTags, + String textBuffer, + Stack stack, + Queue elements, Hackvertor hackvertor) throws ParseException{ if(elements.size() == 0) { if(stack.size() > 0){ String error = String.format("Unclosed tag%s - %s",stack.size()>1?"s":"", @@ -695,11 +695,11 @@ private static String convert(HashMap variables, textBuffer+= ((Element.TextElement) element).getContent(); }else if(element instanceof Element.SelfClosingTag){ //Self closing tag. Just add its output to textbuffer. Element.SelfClosingTag selfClosingTag = (Element.SelfClosingTag) element; - String tagOutput = callTag(variables, customTags, selfClosingTag.getIdentifier(), "", selfClosingTag.getArguments(), null); + String tagOutput = callTag(variables, customTags, selfClosingTag.getIdentifier(), "", selfClosingTag.getArguments(), hackvertor); textBuffer+= tagOutput; }else if(element instanceof Element.StartTag){ //Start of a conversion. stack.push((Element.StartTag) element); - textBuffer+= convert(variables, customTags, "", stack, elements); + textBuffer+= strictConvert(variables, customTags, "", stack, elements, hackvertor); }else if(element instanceof Element.EndTag){ //End of a conversion. Convert and update textbuffer. Element.StartTag startTag; Element.EndTag endTag = (Element.EndTag) element; @@ -712,15 +712,23 @@ private static String convert(HashMap variables, throw new ParseException(String.format("Mismatched opening and closing tags, %s and %s.", startTag.getIdentifier(), endTag.getIdentifier())); } - return callTag(variables, customTags, startTag.getIdentifier(), textBuffer, startTag.getArguments(), null); + return callTag(variables, customTags, startTag.getIdentifier(), textBuffer, startTag.getArguments(), hackvertor); } - return convert(variables, customTags, textBuffer, stack, elements); + return strictConvert(variables, customTags, textBuffer, stack, elements, hackvertor); } - private static Queue weakConvertProcessSetTags(HashMap variables, - JSONArray customTags, - Queue elements) throws ParseException{ + /** + * Process all variable setting tags in a list of tokens, and update the variables map with their values + * @param variables The map of variables and their values + * @param customTags Any custom tags to be processed + * @param elements A list of lexical tokens + * @return + * @throws ParseException + */ + private static Queue weakConvertPreProcessSetTags(HashMap variables, + JSONArray customTags, + Queue elements) throws ParseException{ Queue elementQueue = new LinkedList<>(); Iterator iter = elements.iterator(); while(iter.hasNext()) { @@ -3391,7 +3399,7 @@ static String loop_for(HashMap variableMap, JSONArray customTags String output = ""; for (int i = start; i < end; i += increment) { variableMap.put(variable, Integer.toString(i)); - output += convert(variableMap, customTags, input); + output += weakConvert(variableMap, customTags, input, null); } return output; } @@ -3400,7 +3408,7 @@ static String loop_letters_lower(HashMap variableMap, JSONArray String output = ""; for (char letter = 'a'; letter <= 'z'; letter++) { variableMap.put(variable, Character.toString(letter)); - output += convert(variableMap, customTags, input);; + output += weakConvert(variableMap, customTags, input, null); } return output; } @@ -3409,7 +3417,7 @@ static String loop_letters_upper(HashMap variableMap, JSONArray String output = ""; for (char letter = 'A'; letter <= 'Z'; letter++) { variableMap.put(variable, Character.toString(letter)); - output += convert(variableMap, customTags, input); + output += weakConvert(variableMap, customTags, input, null); } return output; } @@ -3418,7 +3426,7 @@ static String loop_letters_numbers(HashMap variableMap, JSONArra String output = ""; for (char num = '0'; num <= '9'; num++) { variableMap.put(variable, Character.toString(num)); - output += convert(variableMap, customTags, input); + output += weakConvert(variableMap, customTags, input, null); } return output; } diff --git a/src/main/java/burp/ui/HackvertorInput.java b/src/main/java/burp/ui/HackvertorInput.java index b795912..3a74f6e 100644 --- a/src/main/java/burp/ui/HackvertorInput.java +++ b/src/main/java/burp/ui/HackvertorInput.java @@ -30,6 +30,6 @@ public void updateUI() { this.updateFont(); } public void updateFont() { - this.setFont(new Font("Courier New", Font.PLAIN, this.getFont().getSize())); + this.setFont(new Font("Courier New", Font.PLAIN, this.getFont() != null ? this.getFont().getSize() : 11)); } } diff --git a/src/main/java/burp/ui/HackvertorPanel.java b/src/main/java/burp/ui/HackvertorPanel.java index ba4a17f..22bca47 100644 --- a/src/main/java/burp/ui/HackvertorPanel.java +++ b/src/main/java/burp/ui/HackvertorPanel.java @@ -161,9 +161,6 @@ public void actionPerformed(ActionEvent evt) { inputLenLabel.setBackground(Color.decode("#FFF5BF")); inputLenLabel.setBorder(BorderFactory.createLineBorder(Color.decode("#FF9900"), 1)); } - final JTextArea outputArea = new JTextArea(); - outputArea.setFont(new Font("Courier New", Font.PLAIN, 12)); - DocumentListener documentListener = new DocumentListener() { LinkedBlockingQueue queue = new LinkedBlockingQueue<>(1); ExecutorService executorService = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, @@ -171,7 +168,7 @@ public void actionPerformed(ActionEvent evt) { public void scheduleUpdate(){ executorService.submit(() -> { - String output = hackvertor.convert(inputArea.getText()); + String output = hackvertor.convert(inputArea.getText(), null); try { outputArea.getDocument().remove(0, outputArea.getDocument().getLength()); outputArea.getDocument().insertString(0, output, null); From dcc9e007b560ad0c6d4db2da2eec138bf0b56896 Mon Sep 17 00:00:00 2001 From: Corey <1339555+CoreyD97@users.noreply.github.com> Date: Sat, 23 Dec 2023 17:04:41 +0000 Subject: [PATCH 4/8] Automatic JavaCC generation on build --- build.gradle | 15 +- .../java/burp/parser/HackvertorParser.java | 722 ------------- .../parser/HackvertorParserConstants.java | 94 -- .../parser/HackvertorParserTokenManager.java | 955 ------------------ src/main/java/burp/parser/ParseException.java | 193 ---- .../java/burp/parser/SimpleCharStream.java | 474 --------- src/main/java/burp/parser/Token.java | 131 --- src/main/java/burp/parser/TokenMgrError.java | 146 --- .../{java => javacc}/burp/parser/Element.java | 0 .../{java => javacc}/burp/parser/parser.jj | 0 10 files changed, 10 insertions(+), 2720 deletions(-) delete mode 100644 src/main/java/burp/parser/HackvertorParser.java delete mode 100644 src/main/java/burp/parser/HackvertorParserConstants.java delete mode 100644 src/main/java/burp/parser/HackvertorParserTokenManager.java delete mode 100644 src/main/java/burp/parser/ParseException.java delete mode 100644 src/main/java/burp/parser/SimpleCharStream.java delete mode 100644 src/main/java/burp/parser/Token.java delete mode 100644 src/main/java/burp/parser/TokenMgrError.java rename src/main/{java => javacc}/burp/parser/Element.java (100%) rename src/main/{java => javacc}/burp/parser/parser.jj (100%) diff --git a/build.gradle b/build.gradle index 51168b6..965c68c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,7 @@ -apply plugin: 'java' +plugins { + id 'java' + id "org.javacc.javacc" version "3.0.2" +} targetCompatibility = JavaVersion.VERSION_17 sourceCompatibility = JavaVersion.VERSION_17 @@ -37,14 +40,16 @@ dependencies { sourceSets { main { java { - srcDir 'src' - } - resources { - srcDir 'src' + srcDir compileJavacc.outputDirectory } } } +compileJavacc { + inputDirectory = file('src/main/javacc') + include '**/*.java' +} + jar{ duplicatesStrategy = DuplicatesStrategy.EXCLUDE archivesBaseName = project.name + '-all' diff --git a/src/main/java/burp/parser/HackvertorParser.java b/src/main/java/burp/parser/HackvertorParser.java deleted file mode 100644 index 3b27e53..0000000 --- a/src/main/java/burp/parser/HackvertorParser.java +++ /dev/null @@ -1,722 +0,0 @@ -/* HackvertorParser.java */ -/* Generated By:JavaCC: Do not edit this line. HackvertorParser.java */ -package burp.parser; - -import java.io.StringReader; -import java.util.LinkedList; -import java.util.ArrayList; -import org.unbescape.java.JavaEscape; - -public class HackvertorParser implements HackvertorParserConstants { - - private static String getTokenText(Token first, Token cur) { - Token t; - StringBuffer sb = new StringBuffer(); - - for (t=first; t != cur.next; t = t.next) { - if (t.specialToken != null) { - Token tt=t.specialToken; - while (tt.specialToken != null) - tt = tt.specialToken; - for (; tt != null; tt = tt.next) - sb.append(tt.image); - }; - sb.append(t.image); - }; - return sb.toString(); - } - - public static LinkedList parse(String string) throws ParseException { - HackvertorParser parser = new HackvertorParser(new StringReader(string)); - LinkedList elementList = parser.Input(); -// for (Element e : elementList) { -// System.out.println(e.getClass() + " - " + e.toString()); -// } - return elementList; - } - - final public LinkedList Input() throws ParseException {LinkedList s = new LinkedList(); - LinkedList e; - label_1: - while (true) { - switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { - case TAG_START: - case ENDTAG_START: - case TEXT: - case LESSTHAN: - case ST_ERR: - case SELF_CLOSE_TAG_END: - case TAG_END: - case IT_ERR: - case QUOTED_STRING_VAL: - case LITERAL_VAL: - case COMMA: - case ARGS_END: - case ARG_ERR:{ - ; - break; - } - default: - jj_la1[0] = jj_gen; - break label_1; - } - e = ElementSequence(); -s.addAll(e); - } - jj_consume_token(0); -{if ("" != null) return s;} - throw new Error("Missing return statement in function"); -} - - final public LinkedList ElementSequence() throws ParseException {LinkedList elements = new LinkedList(); - Element e; - Token text; - Token firstToken = getToken(1); - try { - switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { - case TAG_START:{ - elements = StartTag(); -{if ("" != null) return elements;} - break; - } - case ENDTAG_START:{ - elements = CloseTag(); -{if ("" != null) return elements;} - break; - } - case LESSTHAN:{ - jj_consume_token(LESSTHAN); -elements.add(new Element.TextElement("<")); {if ("" != null) return elements;} - break; - } - case TEXT: - case ST_ERR: - case SELF_CLOSE_TAG_END: - case TAG_END: - case IT_ERR: - case QUOTED_STRING_VAL: - case LITERAL_VAL: - case COMMA: - case ARGS_END: - case ARG_ERR:{ - switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { - case TEXT:{ - text = jj_consume_token(TEXT); - break; - } - case ST_ERR:{ - text = jj_consume_token(ST_ERR); - break; - } - case IT_ERR:{ - text = jj_consume_token(IT_ERR); - break; - } - case ARG_ERR:{ - text = jj_consume_token(ARG_ERR); - break; - } - case QUOTED_STRING_VAL:{ - text = jj_consume_token(QUOTED_STRING_VAL); - break; - } - case LITERAL_VAL:{ - text = jj_consume_token(LITERAL_VAL); - break; - } - case COMMA:{ - text = jj_consume_token(COMMA); - break; - } - case ARGS_END:{ - text = jj_consume_token(ARGS_END); - break; - } - case TAG_END:{ - text = jj_consume_token(TAG_END); - break; - } - case SELF_CLOSE_TAG_END:{ - text = jj_consume_token(SELF_CLOSE_TAG_END); - break; - } - default: - jj_la1[1] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } -elements.add(new Element.TextElement(text.image)); {if ("" != null) return elements;} - break; - } - default: - jj_la1[2] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } catch (ParseException ex) { -//Catch any unexpected inputs including EOF and try to recover - token_source.SwitchTo(DEFAULT); - elements.addFirst(new Element.TextElement(getTokenText(firstToken, getToken(0)))); - elements.addAll(ElementSequence()); - {if ("" != null) return elements;} - } - throw new Error("Missing return statement in function"); -} - - final public LinkedList StartTag() throws ParseException {LinkedList elements = new LinkedList(); - ArrayList args = new ArrayList(); - LinkedList rest = null; - Token t; - Token identifier = null; - String arg; - Token firstToken = getToken(1); - try { - t = jj_consume_token(TAG_START); - identifier = jj_consume_token(FUNCTION_NAME); - switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { - case ARGS_START:{ - jj_consume_token(ARGS_START); - switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { - case QUOTED_STRING_VAL: - case LITERAL_VAL:{ - arg = Argument(); -args.add(arg); - label_2: - while (true) { - switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { - case COMMA:{ - ; - break; - } - default: - jj_la1[3] = jj_gen; - break label_2; - } - jj_consume_token(COMMA); - arg = Argument(); -args.add(arg); - } - break; - } - default: - jj_la1[4] = jj_gen; - ; - } - jj_consume_token(ARGS_END); - break; - } - default: - jj_la1[5] = jj_gen; - ; - } - switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { - case TAG_END:{ - jj_consume_token(TAG_END); -elements.add(new Element.StartTag(identifier.image, args)); {if ("" != null) return elements;} - break; - } - case SELF_CLOSE_TAG_END: - case SELF_CLOSE_TAG_END_AT:{ - switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { - case SELF_CLOSE_TAG_END:{ - jj_consume_token(SELF_CLOSE_TAG_END); - break; - } - case SELF_CLOSE_TAG_END_AT:{ - jj_consume_token(SELF_CLOSE_TAG_END_AT); - break; - } - default: - jj_la1[6] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } -elements.add(new Element.SelfClosingTag(identifier.image, args)); {if ("" != null) return elements;} - break; - } - default: - jj_la1[7] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } catch (ParseException e) { -// System.out.println("Failed Start tag. Treating as text"); - elements.addFirst(new Element.TextElement(getTokenText(firstToken, getToken(0)))); - } - if (jj_2_1(2)) { - rest = ElementSequence(); - } else { - ; - } -if(rest != null) elements.addAll(rest); {if ("" != null) return elements;} - throw new Error("Missing return statement in function"); -} - - final public String Argument() throws ParseException {Token t; - switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { - case QUOTED_STRING_VAL:{ - t = jj_consume_token(QUOTED_STRING_VAL); -{if ("" != null) return JavaEscape.unescapeJava(t.image.substring(1, t.image.length() - 1));} - break; - } - case LITERAL_VAL:{ - t = jj_consume_token(LITERAL_VAL); -{if ("" != null) return t.image;} - break; - } - default: - jj_la1[8] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); -} - - final public LinkedList CloseTag() throws ParseException {LinkedList elements = new LinkedList(); - LinkedList rest = null; - Token t; - Token firstToken = getToken(1); - try { - jj_consume_token(ENDTAG_START); - t = jj_consume_token(FUNCTION_NAME); - jj_consume_token(TAG_END); -elements.add(new Element.EndTag(t.image)); {if ("" != null) return elements;} - } catch (ParseException e) { -// System.out.println("Failed End tag. Treating as text"); - elements.addFirst(new Element.TextElement(getTokenText(firstToken, getToken(0)))); - } - if (jj_2_2(2)) { - rest = ElementSequence(); - } else { - ; - } -if(rest != null) elements.addAll(rest); {if ("" != null) return elements;} - throw new Error("Missing return statement in function"); -} - - private boolean jj_2_1(int xla) - { - jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return (!jj_3_1()); } - catch(LookaheadSuccess ls) { return true; } - finally { jj_save(0, xla); } - } - - private boolean jj_2_2(int xla) - { - jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return (!jj_3_2()); } - catch(LookaheadSuccess ls) { return true; } - finally { jj_save(1, xla); } - } - - private boolean jj_3R_7() - { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(10)) { - jj_scanpos = xsp; - if (jj_scan_token(13)) { - jj_scanpos = xsp; - if (jj_scan_token(18)) { - jj_scanpos = xsp; - if (jj_scan_token(23)) { - jj_scanpos = xsp; - if (jj_scan_token(19)) { - jj_scanpos = xsp; - if (jj_scan_token(20)) { - jj_scanpos = xsp; - if (jj_scan_token(21)) { - jj_scanpos = xsp; - if (jj_scan_token(22)) { - jj_scanpos = xsp; - if (jj_scan_token(17)) { - jj_scanpos = xsp; - if (jj_scan_token(15)) return true; - } - } - } - } - } - } - } - } - } - return false; - } - - private boolean jj_3R_6() - { - if (jj_scan_token(LESSTHAN)) return true; - return false; - } - - private boolean jj_3_2() - { - if (jj_3R_3()) return true; - return false; - } - - private boolean jj_3R_5() - { - if (jj_3R_9()) return true; - return false; - } - - private boolean jj_3R_8() - { - if (jj_scan_token(TAG_START)) return true; - if (jj_scan_token(FUNCTION_NAME)) return true; - return false; - } - - private boolean jj_3_1() - { - if (jj_3R_3()) return true; - return false; - } - - private boolean jj_3R_4() - { - if (jj_3R_8()) return true; - return false; - } - - private boolean jj_3R_3() - { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_4()) { - jj_scanpos = xsp; - if (jj_3R_5()) { - jj_scanpos = xsp; - if (jj_3R_6()) { - jj_scanpos = xsp; - if (jj_3R_7()) return true; - } - } - } - return false; - } - - private boolean jj_3R_9() - { - if (jj_scan_token(ENDTAG_START)) return true; - if (jj_scan_token(FUNCTION_NAME)) return true; - return false; - } - - /** Generated Token Manager. */ - public HackvertorParserTokenManager token_source; - SimpleCharStream jj_input_stream; - /** Current token. */ - public Token token; - /** Next token. */ - public Token jj_nt; - private int jj_ntk; - private Token jj_scanpos, jj_lastpos; - private int jj_la; - private int jj_gen; - final private int[] jj_la1 = new int[9]; - static private int[] jj_la1_0; - static { - jj_la1_init_0(); - } - private static void jj_la1_init_0() { - jj_la1_0 = new int[] {0xfeaf00,0xfea400,0xfeaf00,0x200000,0x180000,0x4000,0x18000,0x38000,0x180000,}; - } - final private JJCalls[] jj_2_rtns = new JJCalls[2]; - private boolean jj_rescan = false; - private int jj_gc = 0; - - /** Constructor with InputStream. */ - public HackvertorParser(java.io.InputStream stream) { - this(stream, null); - } - /** Constructor with InputStream and supplied encoding */ - public HackvertorParser(java.io.InputStream stream, String encoding) { - try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } - token_source = new HackvertorParserTokenManager(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 9; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream stream) { - ReInit(stream, null); - } - /** Reinitialise. */ - public void ReInit(java.io.InputStream stream, String encoding) { - try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } - token_source.ReInit(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 9; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); - } - - /** Constructor. */ - public HackvertorParser(java.io.Reader stream) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - token_source = new HackvertorParserTokenManager(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 9; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); - } - - /** Reinitialise. */ - public void ReInit(java.io.Reader stream) { - if (jj_input_stream == null) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - } else { - jj_input_stream.ReInit(stream, 1, 1); - } - if (token_source == null) { - token_source = new HackvertorParserTokenManager(jj_input_stream); - } - - token_source.ReInit(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 9; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); - } - - /** Constructor with generated Token Manager. */ - public HackvertorParser(HackvertorParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 9; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); - } - - /** Reinitialise. */ - public void ReInit(HackvertorParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 9; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); - } - - private Token jj_consume_token(int kind) throws ParseException { - Token oldToken; - if ((oldToken = token).next != null) token = token.next; - else token = token.next = token_source.getNextToken(); - jj_ntk = -1; - if (token.kind == kind) { - jj_gen++; - if (++jj_gc > 100) { - jj_gc = 0; - for (int i = 0; i < jj_2_rtns.length; i++) { - JJCalls c = jj_2_rtns[i]; - while (c != null) { - if (c.gen < jj_gen) c.first = null; - c = c.next; - } - } - } - return token; - } - token = oldToken; - jj_kind = kind; - throw generateParseException(); - } - - @SuppressWarnings("serial") - static private final class LookaheadSuccess extends java.lang.Error { } - final private LookaheadSuccess jj_ls = new LookaheadSuccess(); - private boolean jj_scan_token(int kind) { - if (jj_scanpos == jj_lastpos) { - jj_la--; - if (jj_scanpos.next == null) { - jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); - } else { - jj_lastpos = jj_scanpos = jj_scanpos.next; - } - } else { - jj_scanpos = jj_scanpos.next; - } - if (jj_rescan) { - int i = 0; Token tok = token; - while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; } - if (tok != null) jj_add_error_token(kind, i); - } - if (jj_scanpos.kind != kind) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls; - return false; - } - - -/** Get the next Token. */ - final public Token getNextToken() { - if (token.next != null) token = token.next; - else token = token.next = token_source.getNextToken(); - jj_ntk = -1; - jj_gen++; - return token; - } - -/** Get the specific Token. */ - final public Token getToken(int index) { - Token t = token; - for (int i = 0; i < index; i++) { - if (t.next != null) t = t.next; - else t = t.next = token_source.getNextToken(); - } - return t; - } - - private int jj_ntk_f() { - if ((jj_nt=token.next) == null) - return (jj_ntk = (token.next=token_source.getNextToken()).kind); - else - return (jj_ntk = jj_nt.kind); - } - - private java.util.List jj_expentries = new java.util.ArrayList(); - private int[] jj_expentry; - private int jj_kind = -1; - private int[] jj_lasttokens = new int[100]; - private int jj_endpos; - - private void jj_add_error_token(int kind, int pos) { - if (pos >= 100) { - return; - } - - if (pos == jj_endpos + 1) { - jj_lasttokens[jj_endpos++] = kind; - } else if (jj_endpos != 0) { - jj_expentry = new int[jj_endpos]; - - for (int i = 0; i < jj_endpos; i++) { - jj_expentry[i] = jj_lasttokens[i]; - } - - for (int[] oldentry : jj_expentries) { - if (oldentry.length == jj_expentry.length) { - boolean isMatched = true; - - for (int i = 0; i < jj_expentry.length; i++) { - if (oldentry[i] != jj_expentry[i]) { - isMatched = false; - break; - } - - } - if (isMatched) { - jj_expentries.add(jj_expentry); - break; - } - } - } - - if (pos != 0) { - jj_lasttokens[(jj_endpos = pos) - 1] = kind; - } - } - } - - /** Generate ParseException. */ - public ParseException generateParseException() { - jj_expentries.clear(); - boolean[] la1tokens = new boolean[25]; - if (jj_kind >= 0) { - la1tokens[jj_kind] = true; - jj_kind = -1; - } - for (int i = 0; i < 9; i++) { - if (jj_la1[i] == jj_gen) { - for (int j = 0; j < 32; j++) { - if ((jj_la1_0[i] & (1< jj_gen) { - jj_la = p.arg; jj_lastpos = jj_scanpos = p.first; - switch (i) { - case 0: jj_3_1(); break; - case 1: jj_3_2(); break; - } - } - p = p.next; - } while (p != null); - - } catch(LookaheadSuccess ls) { } - } - jj_rescan = false; - } - - private void jj_save(int index, int xla) { - JJCalls p = jj_2_rtns[index]; - while (p.gen > jj_gen) { - if (p.next == null) { p = p.next = new JJCalls(); break; } - p = p.next; - } - - p.gen = jj_gen + xla - jj_la; - p.first = token; - p.arg = xla; - } - - static final class JJCalls { - int gen; - Token first; - int arg; - JJCalls next; - } - -} diff --git a/src/main/java/burp/parser/HackvertorParserConstants.java b/src/main/java/burp/parser/HackvertorParserConstants.java deleted file mode 100644 index 22ac2a7..0000000 --- a/src/main/java/burp/parser/HackvertorParserConstants.java +++ /dev/null @@ -1,94 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. HackvertorParserConstants.java */ -package burp.parser; - - -/** - * Token literal values and constants. - * Generated by org.javacc.parser.OtherFilesGen#start() - */ -public interface HackvertorParserConstants { - - /** End of File. */ - int EOF = 0; - /** RegularExpression Id. */ - int IDENTIFIER = 4; - /** RegularExpression Id. */ - int QUOTED_STRING = 5; - /** RegularExpression Id. */ - int LITERAL = 6; - /** RegularExpression Id. */ - int WHITESPACE = 7; - /** RegularExpression Id. */ - int TAG_START = 8; - /** RegularExpression Id. */ - int ENDTAG_START = 9; - /** RegularExpression Id. */ - int TEXT = 10; - /** RegularExpression Id. */ - int LESSTHAN = 11; - /** RegularExpression Id. */ - int FUNCTION_NAME = 12; - /** RegularExpression Id. */ - int ST_ERR = 13; - /** RegularExpression Id. */ - int ARGS_START = 14; - /** RegularExpression Id. */ - int SELF_CLOSE_TAG_END = 15; - /** RegularExpression Id. */ - int SELF_CLOSE_TAG_END_AT = 16; - /** RegularExpression Id. */ - int TAG_END = 17; - /** RegularExpression Id. */ - int IT_ERR = 18; - /** RegularExpression Id. */ - int QUOTED_STRING_VAL = 19; - /** RegularExpression Id. */ - int LITERAL_VAL = 20; - /** RegularExpression Id. */ - int COMMA = 21; - /** RegularExpression Id. */ - int ARGS_END = 22; - /** RegularExpression Id. */ - int ARG_ERR = 23; - /** RegularExpression Id. */ - int UNKNOWN = 24; - - /** Lexical state. */ - int Args = 0; - /** Lexical state. */ - int InsideTag = 1; - /** Lexical state. */ - int StartTag = 2; - /** Lexical state. */ - int DEFAULT = 3; - - /** Literal token values. */ - String[] tokenImage = { - "", - "\" \"", - "\"=\\r\"", - "\"=\\r\\n\"", - "", - "", - "", - "", - "\"<@\"", - "\"<@/\"", - "", - "\"<\"", - "", - "", - "\"(\"", - "\"/>\"", - "\"@/>\"", - "\">\"", - "", - "", - "", - "\",\"", - "\")\"", - "", - "", - }; - -} diff --git a/src/main/java/burp/parser/HackvertorParserTokenManager.java b/src/main/java/burp/parser/HackvertorParserTokenManager.java deleted file mode 100644 index 61c91f1..0000000 --- a/src/main/java/burp/parser/HackvertorParserTokenManager.java +++ /dev/null @@ -1,955 +0,0 @@ -/* HackvertorParserTokenManager.java */ -/* Generated By:JavaCC: Do not edit this line. HackvertorParserTokenManager.java */ -package burp.parser; -import java.io.StringReader; -import java.util.LinkedList; -import java.util.ArrayList; -import org.unbescape.java.JavaEscape; - -/** Token Manager. */ -public class HackvertorParserTokenManager implements HackvertorParserConstants { - // required by SetState - void backup(int n) { - input_stream.backup(n); - } - - /** Debug output. */ - public java.io.PrintStream debugStream = System.out; - /** Set debug output. */ - public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } -private final int jjStopStringLiteralDfa_3(int pos, long active0){ - switch (pos) - { - case 0: - if ((active0 & 0x2L) != 0L) - return 0; - if ((active0 & 0xcL) != 0L) - { - jjmatchedKind = 10; - return 0; - } - return -1; - case 1: - if ((active0 & 0xcL) != 0L) - return 0; - return -1; - default : - return -1; - } -} -private final int jjStartNfa_3(int pos, long active0){ - return jjMoveNfa_3(jjStopStringLiteralDfa_3(pos, active0), pos + 1); -} -private int jjStopAtPos(int pos, int kind) -{ - jjmatchedKind = kind; - jjmatchedPos = pos; - return pos + 1; -} -private int jjMoveStringLiteralDfa0_3(){ - switch(curChar) - { - case 32: - return jjStartNfaWithStates_3(0, 1, 0); - case 60: - jjmatchedKind = 11; - return jjMoveStringLiteralDfa1_3(0x300L); - case 61: - return jjMoveStringLiteralDfa1_3(0xcL); - default : - return jjMoveNfa_3(0, 0); - } -} -private int jjMoveStringLiteralDfa1_3(long active0){ - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_3(0, active0); - return 1; - } - switch(curChar) - { - case 13: - if ((active0 & 0x4L) != 0L) - { - jjmatchedKind = 2; - jjmatchedPos = 1; - } - return jjMoveStringLiteralDfa2_3(active0, 0x8L); - case 64: - if ((active0 & 0x100L) != 0L) - { - jjmatchedKind = 8; - jjmatchedPos = 1; - } - return jjMoveStringLiteralDfa2_3(active0, 0x200L); - default : - break; - } - return jjStartNfa_3(0, active0); -} -private int jjMoveStringLiteralDfa2_3(long old0, long active0){ - if (((active0 &= old0)) == 0L) - return jjStartNfa_3(0, old0); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_3(1, active0); - return 2; - } - switch(curChar) - { - case 10: - if ((active0 & 0x8L) != 0L) - return jjStartNfaWithStates_3(2, 3, 0); - break; - case 47: - if ((active0 & 0x200L) != 0L) - return jjStopAtPos(2, 9); - break; - default : - break; - } - return jjStartNfa_3(1, active0); -} -private int jjStartNfaWithStates_3(int pos, int kind, int state) -{ - jjmatchedKind = kind; - jjmatchedPos = pos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return pos + 1; } - return jjMoveNfa_3(state, pos + 1); -} -static final long[] jjbitVec0 = { - 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL -}; -static final long[] jjbitVec2 = { - 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL -}; -private int jjMoveNfa_3(int startState, int curPos) -{ - int startsAt = 0; - jjnewStateCnt = 1; - int i = 1; - jjstateSet[0] = startState; - int kind = 0x7fffffff; - for (;;) - { - if (++jjround == 0x7fffffff) - ReInitRounds(); - if (curChar < 64) - { - long l = 1L << curChar; - do - { - switch(jjstateSet[--i]) - { - case 0: - if ((0xefffffffffffffffL & l) == 0L) - break; - kind = 10; - jjstateSet[jjnewStateCnt++] = 0; - break; - default : break; - } - } while(i != startsAt); - } - else if (curChar < 128) - { - long l = 1L << (curChar & 077); - do - { - switch(jjstateSet[--i]) - { - case 0: - kind = 10; - jjstateSet[jjnewStateCnt++] = 0; - break; - default : break; - } - } while(i != startsAt); - } - else - { - int hiByte = (curChar >> 8); - int i1 = hiByte >> 6; - long l1 = 1L << (hiByte & 077); - int i2 = (curChar & 0xff) >> 6; - long l2 = 1L << (curChar & 077); - do - { - switch(jjstateSet[--i]) - { - case 0: - if (!jjCanMove_0(hiByte, i1, i2, l1, l2)) - break; - if (kind > 10) - kind = 10; - jjstateSet[jjnewStateCnt++] = 0; - break; - default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break; - } - } while(i != startsAt); - } - if (kind != 0x7fffffff) - { - jjmatchedKind = kind; - jjmatchedPos = curPos; - kind = 0x7fffffff; - } - ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 1 - (jjnewStateCnt = startsAt))) - return curPos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return curPos; } - } -} -private final int jjStopStringLiteralDfa_0(int pos, long active0){ - switch (pos) - { - default : - return -1; - } -} -private final int jjStartNfa_0(int pos, long active0){ - return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); -} -private int jjMoveStringLiteralDfa0_0(){ - switch(curChar) - { - case 41: - return jjStopAtPos(0, 22); - case 44: - return jjStopAtPos(0, 21); - case 60: - return jjMoveStringLiteralDfa1_0(0x300L); - case 61: - return jjMoveStringLiteralDfa1_0(0xcL); - default : - return jjMoveNfa_0(0, 0); - } -} -private int jjMoveStringLiteralDfa1_0(long active0){ - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(0, active0); - return 1; - } - switch(curChar) - { - case 13: - if ((active0 & 0x4L) != 0L) - { - jjmatchedKind = 2; - jjmatchedPos = 1; - } - return jjMoveStringLiteralDfa2_0(active0, 0x8L); - case 64: - if ((active0 & 0x100L) != 0L) - { - jjmatchedKind = 8; - jjmatchedPos = 1; - } - return jjMoveStringLiteralDfa2_0(active0, 0x200L); - default : - break; - } - return jjStartNfa_0(0, active0); -} -private int jjMoveStringLiteralDfa2_0(long old0, long active0){ - if (((active0 &= old0)) == 0L) - return jjStartNfa_0(0, old0); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(1, active0); - return 2; - } - switch(curChar) - { - case 10: - if ((active0 & 0x8L) != 0L) - return jjStopAtPos(2, 3); - break; - case 47: - if ((active0 & 0x200L) != 0L) - return jjStopAtPos(2, 9); - break; - default : - break; - } - return jjStartNfa_0(1, active0); -} -private int jjMoveNfa_0(int startState, int curPos) -{ - int startsAt = 0; - jjnewStateCnt = 11; - int i = 1; - jjstateSet[0] = startState; - int kind = 0x7fffffff; - for (;;) - { - if (++jjround == 0x7fffffff) - ReInitRounds(); - if (curChar < 64) - { - long l = 1L << curChar; - do - { - switch(jjstateSet[--i]) - { - case 0: - if ((0x3ff680000000000L & l) != 0L) - { - if (kind > 20) - kind = 20; - { jjCheckNAdd(10); } - } - else if (curChar == 34) - { jjCheckNAddStates(0, 2); } - else if (curChar == 39) - { jjCheckNAddStates(3, 5); } - break; - case 2: - { jjCheckNAddStates(3, 5); } - break; - case 3: - if ((0xffffff7fffffffffL & l) != 0L) - { jjCheckNAddStates(3, 5); } - break; - case 4: - if (curChar == 39 && kind > 19) - kind = 19; - break; - case 5: - if (curChar == 34) - { jjCheckNAddStates(0, 2); } - break; - case 7: - { jjCheckNAddStates(0, 2); } - break; - case 8: - if ((0xfffffffbffffffffL & l) != 0L) - { jjCheckNAddStates(0, 2); } - break; - case 9: - if (curChar == 34 && kind > 19) - kind = 19; - break; - case 10: - if ((0x3ff680000000000L & l) == 0L) - break; - if (kind > 20) - kind = 20; - { jjCheckNAdd(10); } - break; - default : break; - } - } while(i != startsAt); - } - else if (curChar < 128) - { - long l = 1L << (curChar & 077); - do - { - switch(jjstateSet[--i]) - { - case 0: - case 10: - if ((0x7fffffe07fffffeL & l) == 0L) - break; - if (kind > 20) - kind = 20; - { jjCheckNAdd(10); } - break; - case 1: - if (curChar == 92) - jjstateSet[jjnewStateCnt++] = 2; - break; - case 2: - { jjCheckNAddStates(3, 5); } - break; - case 3: - if ((0xffffffffefffffffL & l) != 0L) - { jjCheckNAddStates(3, 5); } - break; - case 6: - if (curChar == 92) - jjstateSet[jjnewStateCnt++] = 7; - break; - case 7: - { jjCheckNAddStates(0, 2); } - break; - case 8: - if ((0xffffffffefffffffL & l) != 0L) - { jjCheckNAddStates(0, 2); } - break; - default : break; - } - } while(i != startsAt); - } - else - { - int hiByte = (curChar >> 8); - int i1 = hiByte >> 6; - long l1 = 1L << (hiByte & 077); - int i2 = (curChar & 0xff) >> 6; - long l2 = 1L << (curChar & 077); - do - { - switch(jjstateSet[--i]) - { - case 2: - case 3: - if (jjCanMove_0(hiByte, i1, i2, l1, l2)) - { jjCheckNAddStates(3, 5); } - break; - case 7: - case 8: - if (jjCanMove_0(hiByte, i1, i2, l1, l2)) - { jjCheckNAddStates(0, 2); } - break; - default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break; - } - } while(i != startsAt); - } - if (kind != 0x7fffffff) - { - jjmatchedKind = kind; - jjmatchedPos = curPos; - kind = 0x7fffffff; - } - ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 11 - (jjnewStateCnt = startsAt))) - return curPos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return curPos; } - } -} -private final int jjStopStringLiteralDfa_2(int pos, long active0){ - switch (pos) - { - default : - return -1; - } -} -private final int jjStartNfa_2(int pos, long active0){ - return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0), pos + 1); -} -private int jjMoveStringLiteralDfa0_2(){ - switch(curChar) - { - case 60: - return jjMoveStringLiteralDfa1_2(0x300L); - case 61: - return jjMoveStringLiteralDfa1_2(0xcL); - default : - return jjMoveNfa_2(0, 0); - } -} -private int jjMoveStringLiteralDfa1_2(long active0){ - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_2(0, active0); - return 1; - } - switch(curChar) - { - case 13: - if ((active0 & 0x4L) != 0L) - { - jjmatchedKind = 2; - jjmatchedPos = 1; - } - return jjMoveStringLiteralDfa2_2(active0, 0x8L); - case 64: - if ((active0 & 0x100L) != 0L) - { - jjmatchedKind = 8; - jjmatchedPos = 1; - } - return jjMoveStringLiteralDfa2_2(active0, 0x200L); - default : - break; - } - return jjStartNfa_2(0, active0); -} -private int jjMoveStringLiteralDfa2_2(long old0, long active0){ - if (((active0 &= old0)) == 0L) - return jjStartNfa_2(0, old0); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_2(1, active0); - return 2; - } - switch(curChar) - { - case 10: - if ((active0 & 0x8L) != 0L) - return jjStopAtPos(2, 3); - break; - case 47: - if ((active0 & 0x200L) != 0L) - return jjStopAtPos(2, 9); - break; - default : - break; - } - return jjStartNfa_2(1, active0); -} -private int jjMoveNfa_2(int startState, int curPos) -{ - int startsAt = 0; - jjnewStateCnt = 1; - int i = 1; - jjstateSet[0] = startState; - int kind = 0x7fffffff; - for (;;) - { - if (++jjround == 0x7fffffff) - ReInitRounds(); - if (curChar < 64) - { - long l = 1L << curChar; - do - { - switch(jjstateSet[--i]) - { - case 0: - if ((0x3ff200000000000L & l) == 0L) - break; - kind = 12; - jjstateSet[jjnewStateCnt++] = 0; - break; - default : break; - } - } while(i != startsAt); - } - else if (curChar < 128) - { - long l = 1L << (curChar & 077); - do - { - switch(jjstateSet[--i]) - { - case 0: - if ((0x7fffffe87fffffeL & l) == 0L) - break; - kind = 12; - jjstateSet[jjnewStateCnt++] = 0; - break; - default : break; - } - } while(i != startsAt); - } - else - { - int hiByte = (curChar >> 8); - int i1 = hiByte >> 6; - long l1 = 1L << (hiByte & 077); - int i2 = (curChar & 0xff) >> 6; - long l2 = 1L << (curChar & 077); - do - { - switch(jjstateSet[--i]) - { - default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break; - } - } while(i != startsAt); - } - if (kind != 0x7fffffff) - { - jjmatchedKind = kind; - jjmatchedPos = curPos; - kind = 0x7fffffff; - } - ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 1 - (jjnewStateCnt = startsAt))) - return curPos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return curPos; } - } -} -private int jjMoveStringLiteralDfa0_1(){ - switch(curChar) - { - case 40: - return jjStopAtPos(0, 14); - case 47: - return jjMoveStringLiteralDfa1_1(0x8000L); - case 60: - return jjMoveStringLiteralDfa1_1(0x300L); - case 61: - return jjMoveStringLiteralDfa1_1(0xcL); - case 62: - return jjStopAtPos(0, 17); - case 64: - return jjMoveStringLiteralDfa1_1(0x10000L); - default : - return 1; - } -} -private int jjMoveStringLiteralDfa1_1(long active0){ - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - return 1; - } - switch(curChar) - { - case 13: - if ((active0 & 0x4L) != 0L) - { - jjmatchedKind = 2; - jjmatchedPos = 1; - } - return jjMoveStringLiteralDfa2_1(active0, 0x8L); - case 47: - return jjMoveStringLiteralDfa2_1(active0, 0x10000L); - case 62: - if ((active0 & 0x8000L) != 0L) - return jjStopAtPos(1, 15); - break; - case 64: - if ((active0 & 0x100L) != 0L) - { - jjmatchedKind = 8; - jjmatchedPos = 1; - } - return jjMoveStringLiteralDfa2_1(active0, 0x200L); - default : - return 2; - } - return 2; -} -private int jjMoveStringLiteralDfa2_1(long old0, long active0){ - if (((active0 &= old0)) == 0L) - return 2; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - return 2; - } - switch(curChar) - { - case 10: - if ((active0 & 0x8L) != 0L) - return jjStopAtPos(2, 3); - break; - case 47: - if ((active0 & 0x200L) != 0L) - return jjStopAtPos(2, 9); - break; - case 62: - if ((active0 & 0x10000L) != 0L) - return jjStopAtPos(2, 16); - break; - default : - return 3; - } - return 3; -} - -/** Token literal values. */ -public static final String[] jjstrLiteralImages = { -"", null, null, null, null, null, null, null, "\74\100", "\74\100\57", null, -"\74", null, null, "\50", "\57\76", "\100\57\76", "\76", null, null, null, "\54", -"\51", null, null, }; -protected Token jjFillToken() -{ - final Token t; - final String curTokenImage; - final int beginLine; - final int endLine; - final int beginColumn; - final int endColumn; - String im = jjstrLiteralImages[jjmatchedKind]; - curTokenImage = (im == null) ? input_stream.GetImage() : im; - beginLine = input_stream.getBeginLine(); - beginColumn = input_stream.getBeginColumn(); - endLine = input_stream.getEndLine(); - endColumn = input_stream.getEndColumn(); - t = Token.newToken(jjmatchedKind, curTokenImage); - - t.beginLine = beginLine; - t.endLine = endLine; - t.beginColumn = beginColumn; - t.endColumn = endColumn; - - return t; -} -static final int[] jjnextStates = { - 6, 8, 9, 1, 3, 4, -}; -private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) -{ - switch(hiByte) - { - case 0: - return ((jjbitVec2[i2] & l2) != 0L); - default : - if ((jjbitVec0[i1] & l1) != 0L) - return true; - return false; - } -} - -int curLexState = 3; -int defaultLexState = 3; -int jjnewStateCnt; -int jjround; -int jjmatchedPos; -int jjmatchedKind; - -/** Get the next Token. */ -public Token getNextToken() -{ - Token matchedToken; - int curPos = 0; - - EOFLoop : - for (;;) - { - try - { - curChar = input_stream.BeginToken(); - } - catch(Exception e) - { - jjmatchedKind = 0; - jjmatchedPos = -1; - matchedToken = jjFillToken(); - return matchedToken; - } - - switch(curLexState) - { - case 0: - try { input_stream.backup(0); - while (curChar <= 32 && (0x100000000L & (1L << curChar)) != 0L) - curChar = input_stream.BeginToken(); - } - catch (java.io.IOException e1) { continue EOFLoop; } - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_0(); - if (jjmatchedPos == 0 && jjmatchedKind > 23) - { - jjmatchedKind = 23; - } - break; - case 1: - try { input_stream.backup(0); - while (curChar <= 32 && (0x100000000L & (1L << curChar)) != 0L) - curChar = input_stream.BeginToken(); - } - catch (java.io.IOException e1) { continue EOFLoop; } - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_1(); - if (jjmatchedPos == 0 && jjmatchedKind > 18) - { - jjmatchedKind = 18; - } - break; - case 2: - try { input_stream.backup(0); - while (curChar <= 32 && (0x100000000L & (1L << curChar)) != 0L) - curChar = input_stream.BeginToken(); - } - catch (java.io.IOException e1) { continue EOFLoop; } - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_2(); - if (jjmatchedPos == 0 && jjmatchedKind > 13) - { - jjmatchedKind = 13; - } - break; - case 3: - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_3(); - if (jjmatchedPos == 0 && jjmatchedKind > 24) - { - jjmatchedKind = 24; - } - break; - } - if (jjmatchedKind != 0x7fffffff) - { - if (jjmatchedPos + 1 < curPos) - input_stream.backup(curPos - jjmatchedPos - 1); - if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) - { - matchedToken = jjFillToken(); - if (jjnewLexState[jjmatchedKind] != -1) - curLexState = jjnewLexState[jjmatchedKind]; - return matchedToken; - } - else - { - if (jjnewLexState[jjmatchedKind] != -1) - curLexState = jjnewLexState[jjmatchedKind]; - continue EOFLoop; - } - } - int error_line = input_stream.getEndLine(); - int error_column = input_stream.getEndColumn(); - String error_after = null; - boolean EOFSeen = false; - try { input_stream.readChar(); input_stream.backup(1); } - catch (java.io.IOException e1) { - EOFSeen = true; - error_after = curPos <= 1 ? "" : input_stream.GetImage(); - if (curChar == '\n' || curChar == '\r') { - error_line++; - error_column = 0; - } - else - error_column++; - } - if (!EOFSeen) { - input_stream.backup(1); - error_after = curPos <= 1 ? "" : input_stream.GetImage(); - } - throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); - } -} - -void SkipLexicalActions(Token matchedToken) -{ - switch(jjmatchedKind) - { - default : - break; - } -} -void MoreLexicalActions() -{ - jjimageLen += (lengthOfMatch = jjmatchedPos + 1); - switch(jjmatchedKind) - { - default : - break; - } -} -void TokenLexicalActions(Token matchedToken) -{ - switch(jjmatchedKind) - { - default : - break; - } -} -private void jjCheckNAdd(int state) -{ - if (jjrounds[state] != jjround) - { - jjstateSet[jjnewStateCnt++] = state; - jjrounds[state] = jjround; - } -} -private void jjAddStates(int start, int end) -{ - do { - jjstateSet[jjnewStateCnt++] = jjnextStates[start]; - } while (start++ != end); -} -private void jjCheckNAddTwoStates(int state1, int state2) -{ - jjCheckNAdd(state1); - jjCheckNAdd(state2); -} - -private void jjCheckNAddStates(int start, int end) -{ - do { - jjCheckNAdd(jjnextStates[start]); - } while (start++ != end); -} - - /** Constructor. */ - public HackvertorParserTokenManager(SimpleCharStream stream){ - - if (SimpleCharStream.staticFlag) - throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); - - input_stream = stream; - } - - /** Constructor. */ - public HackvertorParserTokenManager (SimpleCharStream stream, int lexState){ - ReInit(stream); - SwitchTo(lexState); - } - - /** Reinitialise parser. */ - - public void ReInit(SimpleCharStream stream) - { - - - jjmatchedPos = - jjnewStateCnt = - 0; - curLexState = defaultLexState; - input_stream = stream; - ReInitRounds(); - } - - private void ReInitRounds() - { - int i; - jjround = 0x80000001; - for (i = 11; i-- > 0;) - jjrounds[i] = 0x80000000; - } - - /** Reinitialise parser. */ - public void ReInit(SimpleCharStream stream, int lexState) - - { - ReInit(stream); - SwitchTo(lexState); - } - - /** Switch to specified lex state. */ - public void SwitchTo(int lexState) - { - if (lexState >= 4 || lexState < 0) - throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); - else - curLexState = lexState; - } - - -/** Lexer state names. */ -public static final String[] lexStateNames = { - "Args", - "InsideTag", - "StartTag", - "DEFAULT", -}; - -/** Lex State array. */ -public static final int[] jjnewLexState = { - -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, -1, -1, 1, 3, 0, 3, 3, 3, 3, -1, -1, -1, 1, 3, -1, -}; -static final long[] jjtoToken = { - 0x1ffff01L, -}; -static final long[] jjtoSkip = { - 0xeL, -}; -static final long[] jjtoSpecial = { - 0x0L, -}; -static final long[] jjtoMore = { - 0x0L, -}; - protected SimpleCharStream input_stream; - - private final int[] jjrounds = new int[11]; - private final int[] jjstateSet = new int[2 * 11]; - private final StringBuilder jjimage = new StringBuilder(); - private StringBuilder image = jjimage; - private int jjimageLen; - private int lengthOfMatch; - protected int curChar; -} diff --git a/src/main/java/burp/parser/ParseException.java b/src/main/java/burp/parser/ParseException.java deleted file mode 100644 index 791f6d7..0000000 --- a/src/main/java/burp/parser/ParseException.java +++ /dev/null @@ -1,193 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 7.0 */ -/* JavaCCOptions:KEEP_LINE_COLUMN=true */ -package burp.parser; - -/** - * This exception is thrown when parse errors are encountered. - * You can explicitly create objects of this exception type by - * calling the method generateParseException in the generated - * parser. - * - * You can modify this class to customize your error reporting - * mechanisms so long as you retain the public fields. - */ -public class ParseException extends Exception { - - /** - * The version identifier for this Serializable class. - * Increment only if the serialized form of the - * class changes. - */ - private static final long serialVersionUID = 1L; - - /** - * The end of line string for this machine. - */ - protected static String EOL = System.getProperty("line.separator", "\n"); - - /** - * This constructor is used by the method "generateParseException" - * in the generated parser. Calling this constructor generates - * a new object of this type with the fields "currentToken", - * "expectedTokenSequences", and "tokenImage" set. - */ - public ParseException(Token currentTokenVal, - int[][] expectedTokenSequencesVal, - String[] tokenImageVal - ) - { - super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal)); - currentToken = currentTokenVal; - expectedTokenSequences = expectedTokenSequencesVal; - tokenImage = tokenImageVal; - } - - /** - * The following constructors are for use by you for whatever - * purpose you can think of. Constructing the exception in this - * manner makes the exception behave in the normal way - i.e., as - * documented in the class "Throwable". The fields "errorToken", - * "expectedTokenSequences", and "tokenImage" do not contain - * relevant information. The JavaCC generated code does not use - * these constructors. - */ - - public ParseException() { - super(); - } - - /** Constructor with message. */ - public ParseException(String message) { - super(message); - } - - - /** - * This is the last token that has been consumed successfully. If - * this object has been created due to a parse error, the token - * followng this token will (therefore) be the first error token. - */ - public Token currentToken; - - /** - * Each entry in this array is an array of integers. Each array - * of integers represents a sequence of tokens (by their ordinal - * values) that is expected at this point of the parse. - */ - public int[][] expectedTokenSequences; - - /** - * This is a reference to the "tokenImage" array of the generated - * parser within which the parse error occurred. This array is - * defined in the generated ...Constants interface. - */ - public String[] tokenImage; - - /** - * It uses "currentToken" and "expectedTokenSequences" to generate a parse - * error message and returns it. If this object has been created - * due to a parse error, and you do not catch it (it gets thrown - * from the parser) the correct error message - * gets displayed. - */ - private static String initialise(Token currentToken, - int[][] expectedTokenSequences, - String[] tokenImage) { - - StringBuffer expected = new StringBuffer(); - int maxSize = 0; - for (int i = 0; i < expectedTokenSequences.length; i++) { - if (maxSize < expectedTokenSequences[i].length) { - maxSize = expectedTokenSequences[i].length; - } - for (int j = 0; j < expectedTokenSequences[i].length; j++) { - expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' '); - } - if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { - expected.append("..."); - } - expected.append(EOL).append(" "); - } - String retval = "Encountered \""; - Token tok = currentToken.next; - for (int i = 0; i < maxSize; i++) { - if (i != 0) retval += " "; - if (tok.kind == 0) { - retval += tokenImage[0]; - break; - } - retval += " " + tokenImage[tok.kind]; - retval += " \""; - retval += add_escapes(tok.image); - retval += " \""; - tok = tok.next; - } - retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; - retval += "." + EOL; - - - if (expectedTokenSequences.length == 0) { - // Nothing to add here - } else { - if (expectedTokenSequences.length == 1) { - retval += "Was expecting:" + EOL + " "; - } else { - retval += "Was expecting one of:" + EOL + " "; - } - retval += expected.toString(); - } - - return retval; - } - - - /** - * Used to convert raw characters to their escaped version - * when these raw version cannot be used as part of an ASCII - * string literal. - */ - static String add_escapes(String str) { - StringBuffer retval = new StringBuffer(); - char ch; - for (int i = 0; i < str.length(); i++) { - switch (str.charAt(i)) - { - case '\b': - retval.append("\\b"); - continue; - case '\t': - retval.append("\\t"); - continue; - case '\n': - retval.append("\\n"); - continue; - case '\f': - retval.append("\\f"); - continue; - case '\r': - retval.append("\\r"); - continue; - case '\"': - retval.append("\\\""); - continue; - case '\'': - retval.append("\\\'"); - continue; - case '\\': - retval.append("\\\\"); - continue; - default: - if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { - String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" + s.substring(s.length() - 4, s.length())); - } else { - retval.append(ch); - } - continue; - } - } - return retval.toString(); - } - -} -/* JavaCC - OriginalChecksum=e8615de02235cdcf87eafa3d19f881cc (do not edit this line) */ diff --git a/src/main/java/burp/parser/SimpleCharStream.java b/src/main/java/burp/parser/SimpleCharStream.java deleted file mode 100644 index 172f93a..0000000 --- a/src/main/java/burp/parser/SimpleCharStream.java +++ /dev/null @@ -1,474 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 7.0 */ -/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package burp.parser; - -/** - * An implementation of interface CharStream, where the stream is assumed to - * contain only ASCII characters (without unicode processing). - */ - -public class SimpleCharStream -{ -/** Whether parser is static. */ - public static final boolean staticFlag = false; - int bufsize; - int available; - int tokenBegin; -/** Position in buffer. */ - public int bufpos = -1; - protected int bufline[]; - protected int bufcolumn[]; - - protected int column = 0; - protected int line = 1; - - protected boolean prevCharIsCR = false; - protected boolean prevCharIsLF = false; - - protected java.io.Reader inputStream; - - protected char[] buffer; - protected int maxNextCharInd = 0; - protected int inBuf = 0; - protected int tabSize = 1; - protected boolean trackLineColumn = true; - - public void setTabSize(int i) { tabSize = i; } - public int getTabSize() { return tabSize; } - - - - protected void ExpandBuff(boolean wrapAround) - { - char[] newbuffer = new char[bufsize + 2048]; - int newbufline[] = new int[bufsize + 2048]; - int newbufcolumn[] = new int[bufsize + 2048]; - - try - { - if (wrapAround) - { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); - buffer = newbuffer; - - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); - bufline = newbufline; - - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); - bufcolumn = newbufcolumn; - - maxNextCharInd = (bufpos += (bufsize - tokenBegin)); - } - else - { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - buffer = newbuffer; - - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - bufline = newbufline; - - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - bufcolumn = newbufcolumn; - - maxNextCharInd = (bufpos -= tokenBegin); - } - } - catch (Throwable t) - { - throw new Error(t.getMessage()); - } - - - bufsize += 2048; - available = bufsize; - tokenBegin = 0; - } - - protected void FillBuff() throws java.io.IOException - { - if (maxNextCharInd == available) - { - if (available == bufsize) - { - if (tokenBegin > 2048) - { - bufpos = maxNextCharInd = 0; - available = tokenBegin; - } - else if (tokenBegin < 0) - bufpos = maxNextCharInd = 0; - else - ExpandBuff(false); - } - else if (available > tokenBegin) - available = bufsize; - else if ((tokenBegin - available) < 2048) - ExpandBuff(true); - else - available = tokenBegin; - } - - int i; - try { - if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1) - { - inputStream.close(); - throw new java.io.IOException(); - } - else - maxNextCharInd += i; - return; - } - catch(java.io.IOException e) { - --bufpos; - backup(0); - if (tokenBegin == -1) - tokenBegin = bufpos; - throw e; - } - } - -/** Start. */ - public char BeginToken() throws java.io.IOException - { - tokenBegin = -1; - char c = readChar(); - tokenBegin = bufpos; - - return c; - } - - protected void UpdateLineColumn(char c) - { - column++; - - if (prevCharIsLF) - { - prevCharIsLF = false; - line += (column = 1); - } - else if (prevCharIsCR) - { - prevCharIsCR = false; - if (c == '\n') - { - prevCharIsLF = true; - } - else - line += (column = 1); - } - - switch (c) - { - case '\r' : - prevCharIsCR = true; - break; - case '\n' : - prevCharIsLF = true; - break; - case '\t' : - column--; - column += (tabSize - (column % tabSize)); - break; - default : - break; - } - - bufline[bufpos] = line; - bufcolumn[bufpos] = column; - } - -/** Read a character. */ - public char readChar() throws java.io.IOException - { - if (inBuf > 0) - { - --inBuf; - - if (++bufpos == bufsize) - bufpos = 0; - - return buffer[bufpos]; - } - - if (++bufpos >= maxNextCharInd) - FillBuff(); - - char c = buffer[bufpos]; - - UpdateLineColumn(c); - return c; - } - - @Deprecated - /** - * @deprecated - * @see #getEndColumn - */ - - public int getColumn() { - return bufcolumn[bufpos]; - } - - @Deprecated - /** - * @deprecated - * @see #getEndLine - */ - - public int getLine() { - return bufline[bufpos]; - } - - /** Get token end column number. */ - public int getEndColumn() { - return bufcolumn[bufpos]; - } - - /** Get token end line number. */ - public int getEndLine() { - return bufline[bufpos]; - } - - /** Get token beginning column number. */ - public int getBeginColumn() { - return bufcolumn[tokenBegin]; - } - - /** Get token beginning line number. */ - public int getBeginLine() { - return bufline[tokenBegin]; - } - -/** Backup a number of characters. */ - public void backup(int amount) { - - inBuf += amount; - if ((bufpos -= amount) < 0) - bufpos += bufsize; - } - - /** Constructor. */ - public SimpleCharStream(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) - { - inputStream = dstream; - line = startline; - column = startcolumn - 1; - - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - } - - /** Constructor. */ - public SimpleCharStream(java.io.Reader dstream, int startline, - int startcolumn) - { - this(dstream, startline, startcolumn, 4096); - } - - /** Constructor. */ - public SimpleCharStream(java.io.Reader dstream) - { - this(dstream, 1, 1, 4096); - } - - /** Reinitialise. */ - public void ReInit(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) - { - inputStream = dstream; - line = startline; - column = startcolumn - 1; - - if (buffer == null || buffersize != buffer.length) - { - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - } - prevCharIsLF = prevCharIsCR = false; - tokenBegin = inBuf = maxNextCharInd = 0; - bufpos = -1; - } - - /** Reinitialise. */ - public void ReInit(java.io.Reader dstream, int startline, - int startcolumn) - { - ReInit(dstream, startline, startcolumn, 4096); - } - - /** Reinitialise. */ - public void ReInit(java.io.Reader dstream) - { - ReInit(dstream, 1, 1, 4096); - } - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, - int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException - { - this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, int startline, - int startcolumn, int buffersize) - { - this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, - int startcolumn) throws java.io.UnsupportedEncodingException - { - this(dstream, encoding, startline, startcolumn, 4096); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, int startline, - int startcolumn) - { - this(dstream, startline, startcolumn, 4096); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException - { - this(dstream, encoding, 1, 1, 4096); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream) - { - this(dstream, 1, 1, 4096); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, String encoding, int startline, - int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException - { - ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, int startline, - int startcolumn, int buffersize) - { - ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException - { - ReInit(dstream, encoding, 1, 1, 4096); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream) - { - ReInit(dstream, 1, 1, 4096); - } - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, String encoding, int startline, - int startcolumn) throws java.io.UnsupportedEncodingException - { - ReInit(dstream, encoding, startline, startcolumn, 4096); - } - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, int startline, - int startcolumn) - { - ReInit(dstream, startline, startcolumn, 4096); - } - /** Get token literal value. */ - public String GetImage() - { - if (bufpos >= tokenBegin) - return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); - else - return new String(buffer, tokenBegin, bufsize - tokenBegin) + - new String(buffer, 0, bufpos + 1); - } - - /** Get the suffix. */ - public char[] GetSuffix(int len) - { - char[] ret = new char[len]; - - if ((bufpos + 1) >= len) - System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); - else - { - System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, - len - bufpos - 1); - System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); - } - - return ret; - } - - /** Reset buffer when finished. */ - public void Done() - { - buffer = null; - bufline = null; - bufcolumn = null; - } - - /** - * Method to adjust line and column numbers for the start of a token. - */ - public void adjustBeginLineColumn(int newLine, int newCol) - { - int start = tokenBegin; - int len; - - if (bufpos >= tokenBegin) - { - len = bufpos - tokenBegin + inBuf + 1; - } - else - { - len = bufsize - tokenBegin + bufpos + 1 + inBuf; - } - - int i = 0, j = 0, k = 0; - int nextColDiff = 0, columnDiff = 0; - - while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) - { - bufline[j] = newLine; - nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; - bufcolumn[j] = newCol + columnDiff; - columnDiff = nextColDiff; - i++; - } - - if (i < len) - { - bufline[j] = newLine++; - bufcolumn[j] = newCol + columnDiff; - - while (i++ < len) - { - if (bufline[j = start % bufsize] != bufline[++start % bufsize]) - bufline[j] = newLine++; - else - bufline[j] = newLine; - } - } - - line = bufline[j]; - column = bufcolumn[j]; - } - boolean getTrackLineColumn() { return trackLineColumn; } - void setTrackLineColumn(boolean tlc) { trackLineColumn = tlc; } -} -/* JavaCC - OriginalChecksum=e9a4c63c6a32529181bc8c734bcdc46d (do not edit this line) */ diff --git a/src/main/java/burp/parser/Token.java b/src/main/java/burp/parser/Token.java deleted file mode 100644 index bb92c13..0000000 --- a/src/main/java/burp/parser/Token.java +++ /dev/null @@ -1,131 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. Token.java Version 7.0 */ -/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COLUMN=true,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package burp.parser; - -/** - * Describes the input token stream. - */ - -public class Token implements java.io.Serializable { - - /** - * The version identifier for this Serializable class. - * Increment only if the serialized form of the - * class changes. - */ - private static final long serialVersionUID = 1L; - - /** - * An integer that describes the kind of this token. This numbering - * system is determined by JavaCCParser, and a table of these numbers is - * stored in the file ...Constants.java. - */ - public int kind; - - /** The line number of the first character of this Token. */ - public int beginLine; - /** The column number of the first character of this Token. */ - public int beginColumn; - /** The line number of the last character of this Token. */ - public int endLine; - /** The column number of the last character of this Token. */ - public int endColumn; - - /** - * The string image of the token. - */ - public String image; - - /** - * A reference to the next regular (non-special) token from the input - * stream. If this is the last token from the input stream, or if the - * token manager has not read tokens beyond this one, this field is - * set to null. This is true only if this token is also a regular - * token. Otherwise, see below for a description of the contents of - * this field. - */ - public Token next; - - /** - * This field is used to access special tokens that occur prior to this - * token, but after the immediately preceding regular (non-special) token. - * If there are no such special tokens, this field is set to null. - * When there are more than one such special token, this field refers - * to the last of these special tokens, which in turn refers to the next - * previous special token through its specialToken field, and so on - * until the first special token (whose specialToken field is null). - * The next fields of special tokens refer to other special tokens that - * immediately follow it (without an intervening regular token). If there - * is no such token, this field is null. - */ - public Token specialToken; - - /** - * An optional attribute value of the Token. - * Tokens which are not used as syntactic sugar will often contain - * meaningful values that will be used later on by the compiler or - * interpreter. This attribute value is often different from the image. - * Any subclass of Token that actually wants to return a non-null value can - * override this method as appropriate. - */ - public Object getValue() { - return null; - } - - /** - * No-argument constructor - */ - public Token() {} - - /** - * Constructs a new token for the specified Image. - */ - public Token(int kind) - { - this(kind, null); - } - - /** - * Constructs a new token for the specified Image and Kind. - */ - public Token(int kind, String image) - { - this.kind = kind; - this.image = image; - } - - /** - * Returns the image. - */ - public String toString() - { - return image; - } - - /** - * Returns a new Token object, by default. However, if you want, you - * can create and return subclass objects based on the value of ofKind. - * Simply add the cases to the switch for all those special cases. - * For example, if you have a subclass of Token called IDToken that - * you want to create if ofKind is ID, simply add something like : - * - * case MyParserConstants.ID : return new IDToken(ofKind, image); - * - * to the following switch statement. Then you can cast matchedToken - * variable to the appropriate type and use sit in your lexical actions. - */ - public static Token newToken(int ofKind, String image) - { - switch(ofKind) - { - default : return new Token(ofKind, image); - } - } - - public static Token newToken(int ofKind) - { - return newToken(ofKind, null); - } - -} -/* JavaCC - OriginalChecksum=4c00c4075b249dc0bbb9ca9025a068d7 (do not edit this line) */ diff --git a/src/main/java/burp/parser/TokenMgrError.java b/src/main/java/burp/parser/TokenMgrError.java deleted file mode 100644 index 7753079..0000000 --- a/src/main/java/burp/parser/TokenMgrError.java +++ /dev/null @@ -1,146 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 7.0 */ -/* JavaCCOptions: */ -package burp.parser; - -/** Token Manager Error. */ -public class TokenMgrError extends Error -{ - - /** - * The version identifier for this Serializable class. - * Increment only if the serialized form of the - * class changes. - */ - private static final long serialVersionUID = 1L; - - /* - * Ordinals for various reasons why an Error of this type can be thrown. - */ - - /** - * Lexical error occurred. - */ - public static final int LEXICAL_ERROR = 0; - - /** - * An attempt was made to create a second instance of a static token manager. - */ - public static final int STATIC_LEXER_ERROR = 1; - - /** - * Tried to change to an invalid lexical state. - */ - public static final int INVALID_LEXICAL_STATE = 2; - - /** - * Detected (and bailed out of) an infinite loop in the token manager. - */ - public static final int LOOP_DETECTED = 3; - - /** - * Indicates the reason why the exception is thrown. It will have - * one of the above 4 values. - */ - int errorCode; - - /** - * Replaces unprintable characters by their escaped (or unicode escaped) - * equivalents in the given string - */ - protected static final String addEscapes(String str) { - StringBuffer retval = new StringBuffer(); - char ch; - for (int i = 0; i < str.length(); i++) { - switch (str.charAt(i)) - { - case '\b': - retval.append("\\b"); - continue; - case '\t': - retval.append("\\t"); - continue; - case '\n': - retval.append("\\n"); - continue; - case '\f': - retval.append("\\f"); - continue; - case '\r': - retval.append("\\r"); - continue; - case '\"': - retval.append("\\\""); - continue; - case '\'': - retval.append("\\\'"); - continue; - case '\\': - retval.append("\\\\"); - continue; - default: - if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { - String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" + s.substring(s.length() - 4, s.length())); - } else { - retval.append(ch); - } - continue; - } - } - return retval.toString(); - } - - /** - * Returns a detailed message for the Error when it is thrown by the - * token manager to indicate a lexical error. - * Parameters : - * EOFSeen : indicates if EOF caused the lexical error - * curLexState : lexical state in which this error occurred - * errorLine : line number when the error occurred - * errorColumn : column number when the error occurred - * errorAfter : prefix that was seen before this error occurred - * curchar : the offending character - * Note: You can customize the lexical error message by modifying this method. - */ - protected static String LexicalErr(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar) { - char curChar1 = (char)curChar; - return("Lexical error at line " + - errorLine + ", column " + - errorColumn + ". Encountered: " + - (EOFSeen ? " " : ("\"" + addEscapes(String.valueOf(curChar1)) + "\"") + " (" + (int)curChar + "), ") + - "after : \"" + addEscapes(errorAfter) + "\""); - } - - /** - * You can also modify the body of this method to customize your error messages. - * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not - * of end-users concern, so you can return something like : - * - * "Internal Error : Please file a bug report .... " - * - * from this method for such cases in the release version of your parser. - */ - public String getMessage() { - return super.getMessage(); - } - - /* - * Constructors of various flavors follow. - */ - - /** No arg constructor. */ - public TokenMgrError() { - } - - /** Constructor with message and reason. */ - public TokenMgrError(String message, int reason) { - super(message); - errorCode = reason; - } - - /** Full Constructor. */ - public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar, int reason) { - this(LexicalErr(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); - } -} -/* JavaCC - OriginalChecksum=03a2b7fd4dba9b9d2d2a0b1de94b284c (do not edit this line) */ diff --git a/src/main/java/burp/parser/Element.java b/src/main/javacc/burp/parser/Element.java similarity index 100% rename from src/main/java/burp/parser/Element.java rename to src/main/javacc/burp/parser/Element.java diff --git a/src/main/java/burp/parser/parser.jj b/src/main/javacc/burp/parser/parser.jj similarity index 100% rename from src/main/java/burp/parser/parser.jj rename to src/main/javacc/burp/parser/parser.jj From 7d5f8b06fa54cc1fabdf6a0af0c13e3b9a8ac18e Mon Sep 17 00:00:00 2001 From: Corey <1339555+CoreyD97@users.noreply.github.com> Date: Sat, 23 Dec 2023 17:28:35 +0000 Subject: [PATCH 5/8] Setup tests --- build.gradle | 4 + src/main/java/burp/BurpExtender.java | 5 + src/test/java/burp/ConvertorTests.java | 37 +++++ src/test/java/burp/StubExtensionHelpers.java | 148 ++++++++++++++++++ .../burp/parser/HackvertorParserTest.java | 2 + 5 files changed, 196 insertions(+) create mode 100644 src/test/java/burp/ConvertorTests.java create mode 100644 src/test/java/burp/StubExtensionHelpers.java diff --git a/build.gradle b/build.gradle index 965c68c..dbfc451 100644 --- a/build.gradle +++ b/build.gradle @@ -65,4 +65,8 @@ jar{ tasks.withType(Jar) { destinationDirectory = file("$rootDir/releases/") +} + +test { + useJUnitPlatform() } \ No newline at end of file diff --git a/src/main/java/burp/BurpExtender.java b/src/main/java/burp/BurpExtender.java index c6c77dd..d68c45b 100644 --- a/src/main/java/burp/BurpExtender.java +++ b/src/main/java/burp/BurpExtender.java @@ -1733,4 +1733,9 @@ public void alert(String msg) { public Component getUiComponent() { return extensionPanel; } + + //Used in tests + public static void setHelpers(IExtensionHelpers helpers) { + BurpExtender.helpers = helpers; + } } diff --git a/src/test/java/burp/ConvertorTests.java b/src/test/java/burp/ConvertorTests.java new file mode 100644 index 0000000..6bec980 --- /dev/null +++ b/src/test/java/burp/ConvertorTests.java @@ -0,0 +1,37 @@ +package burp; + +import burp.parser.Element; +import burp.parser.HackvertorParser; +import burp.parser.ParseException; +import org.junit.jupiter.api.Test; + +import java.util.LinkedList; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; + +public class ConvertorTests { + + private final Hackvertor hackvertor; + + public ConvertorTests() { + this.hackvertor = new Hackvertor(); + BurpExtender.setHelpers(new StubExtensionHelpers()); + } + + @Test + void convertSpaceInTag() throws ParseException { + String spaceInContent = "<@base64> <@/base64>"; + String converted = hackvertor.convert(spaceInContent, hackvertor); + assertEquals("IA==", converted); + } + + @Test + void parseSpaces() throws ParseException { + String spaceInContent = "<@base64> <@/base64>"; + LinkedList parsed = HackvertorParser.parse(spaceInContent); + assertEquals(3, parsed.size()); + assertInstanceOf(Element.TextElement.class, parsed.get(1)); + assertEquals(" ", parsed.get(1).toString()); + } +} diff --git a/src/test/java/burp/StubExtensionHelpers.java b/src/test/java/burp/StubExtensionHelpers.java new file mode 100644 index 0000000..18462e5 --- /dev/null +++ b/src/test/java/burp/StubExtensionHelpers.java @@ -0,0 +1,148 @@ +package burp; + +import org.python.apache.xerces.impl.dv.util.Base64; + +import java.net.URL; +import java.util.List; + +public class StubExtensionHelpers implements IExtensionHelpers { + @Override + public IRequestInfo analyzeRequest(IHttpRequestResponse request) { + return null; + } + + @Override + public IRequestInfo analyzeRequest(IHttpService httpService, byte[] request) { + return null; + } + + @Override + public IRequestInfo analyzeRequest(byte[] request) { + return null; + } + + @Override + public IResponseInfo analyzeResponse(byte[] response) { + return null; + } + + @Override + public IParameter getRequestParameter(byte[] request, String parameterName) { + return null; + } + + @Override + public String urlDecode(String data) { + return null; + } + + @Override + public String urlEncode(String data) { + return null; + } + + @Override + public byte[] urlDecode(byte[] data) { + return new byte[0]; + } + + @Override + public byte[] urlEncode(byte[] data) { + return new byte[0]; + } + + @Override + public byte[] base64Decode(String data) { + return new byte[0]; + } + + @Override + public byte[] base64Decode(byte[] data) { + return base64Decode(data); + } + + @Override + public String base64Encode(String data) { + return Base64.encode(data.getBytes()); + } + + @Override + public String base64Encode(byte[] data) { + return null; + } + + @Override + public byte[] stringToBytes(String data) { + return new byte[0]; + } + + @Override + public String bytesToString(byte[] data) { + return null; + } + + @Override + public int indexOf(byte[] data, byte[] pattern, boolean caseSensitive, int from, int to) { + return 0; + } + + @Override + public byte[] buildHttpMessage(List headers, byte[] body) { + return new byte[0]; + } + + @Override + public byte[] buildHttpRequest(URL url) { + return new byte[0]; + } + + @Override + public byte[] addParameter(byte[] request, IParameter parameter) { + return new byte[0]; + } + + @Override + public byte[] removeParameter(byte[] request, IParameter parameter) { + return new byte[0]; + } + + @Override + public byte[] updateParameter(byte[] request, IParameter parameter) { + return new byte[0]; + } + + @Override + public byte[] toggleRequestMethod(byte[] request) { + return new byte[0]; + } + + @Override + public IHttpService buildHttpService(String host, int port, String protocol) { + return null; + } + + @Override + public IHttpService buildHttpService(String host, int port, boolean useHttps) { + return null; + } + + @Override + public IParameter buildParameter(String name, String value, byte type) { + return null; + } + + @Override + public IScannerInsertionPoint makeScannerInsertionPoint(String insertionPointName, byte[] baseRequest, int from, int to) { + return null; + } + + @Override + public IResponseVariations analyzeResponseVariations(byte[]... responses) { + return null; + } + + @Override + public IResponseKeywords analyzeResponseKeywords(List keywords, byte[]... responses) { + return null; + } +} diff --git a/src/test/java/burp/parser/HackvertorParserTest.java b/src/test/java/burp/parser/HackvertorParserTest.java index 57d6dea..9efc9a4 100644 --- a/src/test/java/burp/parser/HackvertorParserTest.java +++ b/src/test/java/burp/parser/HackvertorParserTest.java @@ -1,6 +1,8 @@ package burp.parser; import org.junit.jupiter.api.Test; +import java.util.LinkedList; + import static org.junit.jupiter.api.Assertions.*; class HackvertorParserTest { From d577b621feea4519b64b13f87b0fce7175da73da Mon Sep 17 00:00:00 2001 From: Corey <1339555+CoreyD97@users.noreply.github.com> Date: Sat, 23 Dec 2023 17:30:52 +0000 Subject: [PATCH 6/8] Move parser test --- src/test/java/burp/ConvertorTests.java | 9 --------- src/test/java/burp/parser/HackvertorParserTest.java | 9 +++++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/test/java/burp/ConvertorTests.java b/src/test/java/burp/ConvertorTests.java index 6bec980..b7249d3 100644 --- a/src/test/java/burp/ConvertorTests.java +++ b/src/test/java/burp/ConvertorTests.java @@ -25,13 +25,4 @@ void convertSpaceInTag() throws ParseException { String converted = hackvertor.convert(spaceInContent, hackvertor); assertEquals("IA==", converted); } - - @Test - void parseSpaces() throws ParseException { - String spaceInContent = "<@base64> <@/base64>"; - LinkedList parsed = HackvertorParser.parse(spaceInContent); - assertEquals(3, parsed.size()); - assertInstanceOf(Element.TextElement.class, parsed.get(1)); - assertEquals(" ", parsed.get(1).toString()); - } } diff --git a/src/test/java/burp/parser/HackvertorParserTest.java b/src/test/java/burp/parser/HackvertorParserTest.java index 9efc9a4..c797700 100644 --- a/src/test/java/burp/parser/HackvertorParserTest.java +++ b/src/test/java/burp/parser/HackvertorParserTest.java @@ -19,4 +19,13 @@ void parseUnicode2() { HackvertorParser.parse("’"); }); } + + @Test + void parseSpaces() throws ParseException { + String spaceInContent = "<@base64> <@/base64>"; + LinkedList parsed = HackvertorParser.parse(spaceInContent); + assertEquals(3, parsed.size()); + assertInstanceOf(Element.TextElement.class, parsed.get(1)); + assertEquals(" ", parsed.get(1).toString()); + } } \ No newline at end of file From 6bcc62ed8a7868bf1c263626fdc7aff53996bc2b Mon Sep 17 00:00:00 2001 From: Corey <1339555+CoreyD97@users.noreply.github.com> Date: Sat, 23 Dec 2023 17:34:32 +0000 Subject: [PATCH 7/8] Add test for #92 --- src/test/java/burp/ConvertorTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/java/burp/ConvertorTests.java b/src/test/java/burp/ConvertorTests.java index b7249d3..ed65b54 100644 --- a/src/test/java/burp/ConvertorTests.java +++ b/src/test/java/burp/ConvertorTests.java @@ -25,4 +25,15 @@ void convertSpaceInTag() throws ParseException { String converted = hackvertor.convert(spaceInContent, hackvertor); assertEquals("IA==", converted); } + + //Test for #92. + @Test + void testSpaceInAttribute(){ + String plaintext = "<@ascii2hex('')>abcd<@/ascii2hex>"; + assertEquals("61626364", hackvertor.convert(plaintext, hackvertor)); + plaintext = "<@ascii2hex(' ')>abcd<@/ascii2hex>"; + assertEquals("61 62 63 64", hackvertor.convert(plaintext, hackvertor)); + plaintext = "<@ascii2hex(' ')>abcd<@/ascii2hex>"; + assertEquals("61 62 63 64", hackvertor.convert(plaintext, hackvertor)); + } } From e0a6ae6479487b2d6abf83df8a85091bdc5739c1 Mon Sep 17 00:00:00 2001 From: Corey <1339555+CoreyD97@users.noreply.github.com> Date: Sat, 23 Dec 2023 17:35:41 +0000 Subject: [PATCH 8/8] Fixes #92 whitespace issue in parser --- src/main/javacc/burp/parser/parser.jj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/javacc/burp/parser/parser.jj b/src/main/javacc/burp/parser/parser.jj index ecd22e7..919c76c 100644 --- a/src/main/javacc/burp/parser/parser.jj +++ b/src/main/javacc/burp/parser/parser.jj @@ -55,7 +55,7 @@ TOKEN_MGR_DECLS : { } } -<*> SKIP: { " " | "=\r" | "=\r\n" } +<*> SKIP: { "=\r" | "=\r\n" } <*> TOKEN [IGNORE_CASE]: { <#IDENTIFIER: (["0"-"9", "a"-"z", "A"-"Z","_", "-"])+ > | <#QUOTED_STRING: ( "'" ("\\" ~[] | ~["'", "\\"] )* "'" ) | ( "\"" ("\\" ~[] | ~["\"", "\\"] )* "\"" ) >