Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

tests for updated hlint parser

  • Loading branch information...
commit d65f2424d75ecd06a4c81c1e9ebd3157d10d2b95 1 parent 1c17f82
@JPMoresmau authored
Showing with 1,137 additions and 797 deletions.
  1. +8 −0 net.sf.eclipsefp.haskell.hlint.test/.classpath
  2. +17 −0 net.sf.eclipsefp.haskell.hlint.test/.project
  3. +12 −0 net.sf.eclipsefp.haskell.hlint.test/.settings/org.eclipse.jdt.core.prefs
  4. +62 −0 net.sf.eclipsefp.haskell.hlint.test/src/net/sf/eclipsefp/haskell/hlint/parser/OutputParserTest.java
  5. +20 −0 net.sf.eclipsefp.haskell.hlint.test/src/net/sf/eclipsefp/haskell/hlint/parser/testU.txt
  6. +20 −0 net.sf.eclipsefp.haskell.hlint.test/src/net/sf/eclipsefp/haskell/hlint/parser/testW.txt
  7. +851 −753 net.sf.eclipsefp.haskell.hlint/src/net/sf/eclipsefp/haskell/hlint/parser/OutputParser.java
  8. +108 −21 net.sf.eclipsefp.haskell.hlint/src/net/sf/eclipsefp/haskell/hlint/parser/OutputParser.jj
  9. +4 −1 net.sf.eclipsefp.haskell.hlint/src/net/sf/eclipsefp/haskell/hlint/parser/OutputParserConstants.java
  10. +31 −18 net.sf.eclipsefp.haskell.hlint/src/net/sf/eclipsefp/haskell/hlint/parser/OutputParserTokenManager.java
  11. +1 −1  net.sf.eclipsefp.haskell.hlint/src/net/sf/eclipsefp/haskell/hlint/parser/ParseException.java
  12. +1 −1  net.sf.eclipsefp.haskell.hlint/src/net/sf/eclipsefp/haskell/hlint/parser/SimpleCharStream.java
  13. +1 −1  net.sf.eclipsefp.haskell.hlint/src/net/sf/eclipsefp/haskell/hlint/parser/Token.java
  14. +1 −1  net.sf.eclipsefp.haskell.hlint/src/net/sf/eclipsefp/haskell/hlint/parser/TokenMgrError.java
View
8 net.sf.eclipsefp.haskell.hlint.test/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/net.sf.eclipsefp.haskell.hlint"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
View
17 net.sf.eclipsefp.haskell.hlint.test/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>net.sf.eclipsefp.haskell.hlint.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
View
12 net.sf.eclipsefp.haskell.hlint.test/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Wed Aug 24 18:49:56 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
View
62 ...ipsefp.haskell.hlint.test/src/net/sf/eclipsefp/haskell/hlint/parser/OutputParserTest.java
@@ -0,0 +1,62 @@
+package net.sf.eclipsefp.haskell.hlint.parser;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import net.sf.eclipsefp.haskell.hlint.CodeModificationText;
+import net.sf.eclipsefp.haskell.hlint.SourceLocation;
+import net.sf.eclipsefp.haskell.hlint.Suggestion;
+
+import org.junit.Test;
+
+/**
+ * Tests the hlint output parser
+ * @author JP Moresmau
+ *
+ */
+public class OutputParserTest {
+
+ @Test
+ public void testWindowsLongPath() throws Exception{
+ //File f=new File("test.txt");
+ OutputParser p=new OutputParser(OutputParserTest.class.getResourceAsStream("testW.txt"));
+ List<Suggestion> sugs=p.suggestions();
+ assertNotNull(sugs);
+ assertEquals(3, sugs.size());
+ Suggestion sug=sugs.get(0);
+ assertEquals("Unused LANGUAGE pragma",sug.getMessage());
+ SourceLocation sl=sug.getLocation();
+ assertNotNull(sl);
+ assertEquals("D:\\dev\\haskell\\jp-github\\runtime-New_configuration\\scion\\server\\Scion\\Server\\Protocol.hs",sl.getFilename());
+ assertEquals(1,sl.getLine());
+ assertEquals(1,sl.getColumn());
+ assertTrue(sug.getPre() instanceof CodeModificationText);
+ assertEquals("{-# LANGUAGE ExistentialQuantification, TypeSynonymInstances,\n PatternGuards #-}",((CodeModificationText)sug.getPre()).getText());
+ assertTrue(sug.getPost() instanceof CodeModificationText);
+ assertEquals("{-# LANGUAGE ExistentialQuantification, TypeSynonymInstances #-}",((CodeModificationText)sug.getPost()).getText());
+ }
+
+ @Test
+ public void testUnixLongPath() throws Exception{
+ //File f=new File("test.txt");
+ OutputParser p=new OutputParser(OutputParserTest.class.getResourceAsStream("testU.txt"));
+ List<Suggestion> sugs=p.suggestions();
+ assertNotNull(sugs);
+ assertEquals(3, sugs.size());
+ Suggestion sug=sugs.get(0);
+ assertEquals("Unused LANGUAGE pragma",sug.getMessage());
+ SourceLocation sl=sug.getLocation();
+ assertNotNull(sl);
+ assertEquals("/dev/haskell/jp-github/runtime-New_configuration/scion/server/Scion/Server/Protocol.hs",sl.getFilename());
+ assertEquals(1,sl.getLine());
+ assertEquals(1,sl.getColumn());
+ assertTrue(sug.getPre() instanceof CodeModificationText);
+ assertEquals("{-# LANGUAGE ExistentialQuantification, TypeSynonymInstances,\n PatternGuards #-}",((CodeModificationText)sug.getPre()).getText());
+ assertTrue(sug.getPost() instanceof CodeModificationText);
+ assertEquals("{-# LANGUAGE ExistentialQuantification, TypeSynonymInstances #-}",((CodeModificationText)sug.getPost()).getText());
+ }
+
+}
View
20 net.sf.eclipsefp.haskell.hlint.test/src/net/sf/eclipsefp/haskell/hlint/parser/testU.txt
@@ -0,0 +1,20 @@
+/dev/haskell/jp-github/runtime-New_configuration/scion/server/Scion/Server/Protocol.hs:1:1: Error: Unused LANGUAGE pragma
+Found:
+ {-# LANGUAGE ExistentialQuantification, TypeSynonymInstances,
+ PatternGuards #-}
+Why not:
+ {-# LANGUAGE ExistentialQuantification, TypeSynonymInstances #-}
+
+/dev/haskell/jp-github/runtime-New_configuration/scion/server/Scion/Server/Protocol.hs:92:14: Error: Redundant do
+Found:
+ do (c :) `fmap` munchmunch (c == '\\')
+Why not:
+ (c :) `fmap` munchmunch (c == '\\')
+
+/dev/haskell/jp-github/runtime-New_configuration/scion/server/Scion/Server/Protocol.hs:96:10: Warning: Use fmap
+Found:
+ munch1 isDigit >>= return . read
+Why not:
+ fmap read (munch1 isDigit)
+
+3 suggestions
View
20 net.sf.eclipsefp.haskell.hlint.test/src/net/sf/eclipsefp/haskell/hlint/parser/testW.txt
@@ -0,0 +1,20 @@
+D:\\dev\\haskell\\jp-github\\runtime-New_configuration\\scion\\server\\Scion\\Server\\Protocol.hs:1:1: Error: Unused LANGUAGE pragma
+Found:
+ {-# LANGUAGE ExistentialQuantification, TypeSynonymInstances,
+ PatternGuards #-}
+Why not:
+ {-# LANGUAGE ExistentialQuantification, TypeSynonymInstances #-}
+
+D:\\dev\\haskell\\jp-github\\runtime-New_configuration\\scion\\server\\Scion\\Server\\Protocol.hs:92:14: Error: Redundant do
+Found:
+ do (c :) `fmap` munchmunch (c == '\\')
+Why not:
+ (c :) `fmap` munchmunch (c == '\\')
+
+D:\\dev\\haskell\\jp-github\\runtime-New_configuration\\scion\\server\\Scion\\Server\\Protocol.hs:96:10: Warning: Use fmap
+Found:
+ munch1 isDigit >>= return . read
+Why not:
+ fmap read (munch1 isDigit)
+
+3 suggestions
View
1,604 net.sf.eclipsefp.haskell.hlint/src/net/sf/eclipsefp/haskell/hlint/parser/OutputParser.java
@@ -1,753 +1,851 @@
-/* Generated By:JavaCC: Do not edit this line. OutputParser.java */
-package net.sf.eclipsefp.haskell.hlint.parser;
-
-import java.util.*;
-import net.sf.eclipsefp.haskell.hlint.*;
-
-public class OutputParser implements OutputParserConstants {
-
- final public List<Suggestion> suggestions() throws ParseException {
- ArrayList<Suggestion > sugs;
- Suggestion sug;
- if (jj_2_2(100)) {
- string_until_eol();
- jj_consume_token(0);
- {if (true) return new ArrayList<Suggestion>();}
- } else if (jj_2_3(100)) {
- sug = suggestion();
- sugs = new ArrayList<Suggestion>();
- sugs.add(sug);
- label_1:
- while (true) {
- if (jj_2_1(100)) {
- ;
- } else {
- break label_1;
- }
- sug = suggestion();
- sugs.add(sug);
- }
- string_until_eol();
- jj_consume_token(0);
- {if (true) return sugs;}
- } else {
- jj_consume_token(-1);
- throw new ParseException();
- }
- throw new Error("Missing return statement in function");
- }
-
- final public Suggestion suggestion() throws ParseException {
- StringBuilder filename;
- Integer line;
- Integer column;
- Severity sev;
- StringBuilder message;
- CodeModification pre;
- CodeModification post;
- filename = string_until_colon();
- line = number();
- column = number();
- jj_consume_token(SPACE);
- sev = severity();
- jj_consume_token(SPACE);
- message = string_until_eol();
- pre = code_mod();
- post = code_mod();
- jj_consume_token(EOL);
- Suggestion s = new Suggestion();
- s.setLocation(new SourceLocation(filename.toString(), line, column));
- s.setSeverity(sev);
- s.setMessage(message.toString());
- s.setPre(pre);
- s.setPost(post);
- {if (true) return s;}
- throw new Error("Missing return statement in function");
- }
-
- final public StringBuilder string_until_colon() throws ParseException {
- Token c;
- Token c1, c2;
- StringBuilder s;
- if (jj_2_4(100)) {
- c = jj_consume_token(OTHER_CHAR);
- s = string_until_colon();
- s.insert(0, c.image);
- {if (true) return s;}
- } else if (jj_2_5(100)) {
- c = jj_consume_token(SPACE);
- s = string_until_colon();
- s.insert(0, c.image);
- {if (true) return s;}
- } else if (jj_2_6(100)) {
- c = jj_consume_token(COLON_SLASH);
- s = string_until_colon();
- s.insert(0, c.image);
- {if (true) return s;}
- } else if (jj_2_7(100)) {
- jj_consume_token(COLON);
- {if (true) return new StringBuilder();}
- } else {
- jj_consume_token(-1);
- throw new ParseException();
- }
- throw new Error("Missing return statement in function");
- }
-
- final public StringBuilder string_until_eol() throws ParseException {
- Token c;
- StringBuilder s;
- if (jj_2_8(100)) {
- c = jj_consume_token(OTHER_CHAR);
- s = string_until_eol();
- s.insert(0, c.image);
- {if (true) return s;}
- } else if (jj_2_9(100)) {
- c = jj_consume_token(SPACE);
- s = string_until_eol();
- s.insert(0, c.image);
- {if (true) return s;}
- } else if (jj_2_10(100)) {
- c = jj_consume_token(COLON_SLASH);
- s = string_until_eol();
- s.insert(0, c.image);
- {if (true) return s;}
- } else if (jj_2_11(100)) {
- c = jj_consume_token(COLON);
- s = string_until_eol();
- s.insert(0, c.image);
- {if (true) return s;}
- } else if (jj_2_12(100)) {
- jj_consume_token(EOL);
- {if (true) return new StringBuilder();}
- } else {
- jj_consume_token(-1);
- throw new ParseException();
- }
- throw new Error("Missing return statement in function");
- }
-
- final public Integer number() throws ParseException {
- StringBuilder sb;
- sb = string_until_colon();
- {if (true) return Integer.valueOf(sb.toString());}
- throw new Error("Missing return statement in function");
- }
-
- final public Severity severity() throws ParseException {
- StringBuilder sb;
- sb = string_until_colon();
- String s = sb.toString();
- if (s.equals("Ignore"))
- {if (true) return Severity.IGNORE;}
- else if (s.equals("Warning"))
- {if (true) return Severity.WARNING;}
- else if (s.equals("Error"))
- {if (true) return Severity.ERROR;}
- else
- {if (true) return null;}
- throw new Error("Missing return statement in function");
- }
-
- final public CodeModification code_mod() throws ParseException {
- StringBuilder s;
- string_until_eol();
- s = null;
- if (jj_2_13(100)) {
- s = source_code();
- } else {
- ;
- }
- if (s != null)
- {if (true) return new CodeModificationText(s.toString());}
- else
- {if (true) return new CodeModificationRemove();}
- throw new Error("Missing return statement in function");
- }
-
- final public StringBuilder source_code_line() throws ParseException {
- StringBuilder line;
- jj_consume_token(SPACE);
- jj_consume_token(SPACE);
- line = string_until_eol();
- {if (true) return line;}
- throw new Error("Missing return statement in function");
- }
-
- final public StringBuilder source_code() throws ParseException {
- StringBuilder line;
- StringBuilder all;
- all = source_code_line();
- label_2:
- while (true) {
- if (jj_2_14(100)) {
- ;
- } else {
- break label_2;
- }
- line = source_code_line();
- all.append('\u005cn');
- all.append(line.toString());
- }
- {if (true) return all;}
- 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_2_3(int xla) {
- jj_la = xla; jj_lastpos = jj_scanpos = token;
- try { return !jj_3_3(); }
- catch(LookaheadSuccess ls) { return true; }
- finally { jj_save(2, xla); }
- }
-
- private boolean jj_2_4(int xla) {
- jj_la = xla; jj_lastpos = jj_scanpos = token;
- try { return !jj_3_4(); }
- catch(LookaheadSuccess ls) { return true; }
- finally { jj_save(3, xla); }
- }
-
- private boolean jj_2_5(int xla) {
- jj_la = xla; jj_lastpos = jj_scanpos = token;
- try { return !jj_3_5(); }
- catch(LookaheadSuccess ls) { return true; }
- finally { jj_save(4, xla); }
- }
-
- private boolean jj_2_6(int xla) {
- jj_la = xla; jj_lastpos = jj_scanpos = token;
- try { return !jj_3_6(); }
- catch(LookaheadSuccess ls) { return true; }
- finally { jj_save(5, xla); }
- }
-
- private boolean jj_2_7(int xla) {
- jj_la = xla; jj_lastpos = jj_scanpos = token;
- try { return !jj_3_7(); }
- catch(LookaheadSuccess ls) { return true; }
- finally { jj_save(6, xla); }
- }
-
- private boolean jj_2_8(int xla) {
- jj_la = xla; jj_lastpos = jj_scanpos = token;
- try { return !jj_3_8(); }
- catch(LookaheadSuccess ls) { return true; }
- finally { jj_save(7, xla); }
- }
-
- private boolean jj_2_9(int xla) {
- jj_la = xla; jj_lastpos = jj_scanpos = token;
- try { return !jj_3_9(); }
- catch(LookaheadSuccess ls) { return true; }
- finally { jj_save(8, xla); }
- }
-
- private boolean jj_2_10(int xla) {
- jj_la = xla; jj_lastpos = jj_scanpos = token;
- try { return !jj_3_10(); }
- catch(LookaheadSuccess ls) { return true; }
- finally { jj_save(9, xla); }
- }
-
- private boolean jj_2_11(int xla) {
- jj_la = xla; jj_lastpos = jj_scanpos = token;
- try { return !jj_3_11(); }
- catch(LookaheadSuccess ls) { return true; }
- finally { jj_save(10, xla); }
- }
-
- private boolean jj_2_12(int xla) {
- jj_la = xla; jj_lastpos = jj_scanpos = token;
- try { return !jj_3_12(); }
- catch(LookaheadSuccess ls) { return true; }
- finally { jj_save(11, xla); }
- }
-
- private boolean jj_2_13(int xla) {
- jj_la = xla; jj_lastpos = jj_scanpos = token;
- try { return !jj_3_13(); }
- catch(LookaheadSuccess ls) { return true; }
- finally { jj_save(12, xla); }
- }
-
- private boolean jj_2_14(int xla) {
- jj_la = xla; jj_lastpos = jj_scanpos = token;
- try { return !jj_3_14(); }
- catch(LookaheadSuccess ls) { return true; }
- finally { jj_save(13, xla); }
- }
-
- private boolean jj_3R_6() {
- if (jj_3R_7()) return true;
- Token xsp;
- while (true) {
- xsp = jj_scanpos;
- if (jj_3_14()) { jj_scanpos = xsp; break; }
- }
- return false;
- }
-
- private boolean jj_3_2() {
- if (jj_3R_4()) return true;
- if (jj_scan_token(0)) return true;
- return false;
- }
-
- private boolean jj_3_8() {
- if (jj_scan_token(OTHER_CHAR)) return true;
- if (jj_3R_4()) return true;
- return false;
- }
-
- private boolean jj_3R_4() {
- Token xsp;
- xsp = jj_scanpos;
- if (jj_3_8()) {
- jj_scanpos = xsp;
- if (jj_3_9()) {
- jj_scanpos = xsp;
- if (jj_3_10()) {
- jj_scanpos = xsp;
- if (jj_3_11()) {
- jj_scanpos = xsp;
- if (jj_3_12()) return true;
- }
- }
- }
- }
- return false;
- }
-
- private boolean jj_3R_9() {
- if (jj_3R_5()) return true;
- return false;
- }
-
- private boolean jj_3R_7() {
- if (jj_scan_token(SPACE)) return true;
- if (jj_scan_token(SPACE)) return true;
- if (jj_3R_4()) return true;
- return false;
- }
-
- private boolean jj_3R_3() {
- if (jj_3R_5()) return true;
- if (jj_3R_8()) return true;
- if (jj_3R_8()) return true;
- if (jj_scan_token(SPACE)) return true;
- if (jj_3R_9()) return true;
- if (jj_scan_token(SPACE)) return true;
- if (jj_3R_4()) return true;
- if (jj_3R_10()) return true;
- if (jj_3R_10()) return true;
- if (jj_scan_token(EOL)) return true;
- return false;
- }
-
- private boolean jj_3R_8() {
- if (jj_3R_5()) return true;
- return false;
- }
-
- private boolean jj_3_7() {
- if (jj_scan_token(COLON)) return true;
- return false;
- }
-
- private boolean jj_3_6() {
- if (jj_scan_token(COLON_SLASH)) return true;
- if (jj_3R_5()) return true;
- return false;
- }
-
- private boolean jj_3_13() {
- if (jj_3R_6()) return true;
- return false;
- }
-
- private boolean jj_3_12() {
- if (jj_scan_token(EOL)) return true;
- return false;
- }
-
- private boolean jj_3_5() {
- if (jj_scan_token(SPACE)) return true;
- if (jj_3R_5()) return true;
- return false;
- }
-
- private boolean jj_3R_10() {
- if (jj_3R_4()) return true;
- Token xsp;
- xsp = jj_scanpos;
- if (jj_3_13()) jj_scanpos = xsp;
- return false;
- }
-
- private boolean jj_3_11() {
- if (jj_scan_token(COLON)) return true;
- if (jj_3R_4()) return true;
- return false;
- }
-
- private boolean jj_3_4() {
- if (jj_scan_token(OTHER_CHAR)) return true;
- if (jj_3R_5()) return true;
- return false;
- }
-
- private boolean jj_3R_5() {
- Token xsp;
- xsp = jj_scanpos;
- if (jj_3_4()) {
- jj_scanpos = xsp;
- if (jj_3_5()) {
- jj_scanpos = xsp;
- if (jj_3_6()) {
- jj_scanpos = xsp;
- if (jj_3_7()) return true;
- }
- }
- }
- return false;
- }
-
- private boolean jj_3_1() {
- if (jj_3R_3()) return true;
- return false;
- }
-
- private boolean jj_3_10() {
- if (jj_scan_token(COLON_SLASH)) return true;
- if (jj_3R_4()) return true;
- return false;
- }
-
- private boolean jj_3_14() {
- if (jj_3R_7()) return true;
- return false;
- }
-
- private boolean jj_3_3() {
- if (jj_3R_3()) return true;
- Token xsp;
- while (true) {
- xsp = jj_scanpos;
- if (jj_3_1()) { jj_scanpos = xsp; break; }
- }
- if (jj_3R_4()) return true;
- if (jj_scan_token(0)) return true;
- return false;
- }
-
- private boolean jj_3_9() {
- if (jj_scan_token(SPACE)) return true;
- if (jj_3R_4()) return true;
- return false;
- }
-
- /** Generated Token Manager. */
- public OutputParserTokenManager 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[0];
- static private int[] jj_la1_0;
- static {
- jj_la1_init_0();
- }
- private static void jj_la1_init_0() {
- jj_la1_0 = new int[] {};
- }
- final private JJCalls[] jj_2_rtns = new JJCalls[14];
- private boolean jj_rescan = false;
- private int jj_gc = 0;
-
- /** Constructor with InputStream. */
- public OutputParser(java.io.InputStream stream) {
- this(stream, null);
- }
- /** Constructor with InputStream and supplied encoding */
- public OutputParser(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 OutputParserTokenManager(jj_input_stream);
- token = new Token();
- jj_ntk = -1;
- jj_gen = 0;
- for (int i = 0; i < 0; 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 < 0; i++) jj_la1[i] = -1;
- for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
- }
-
- /** Constructor. */
- public OutputParser(java.io.Reader stream) {
- jj_input_stream = new SimpleCharStream(stream, 1, 1);
- token_source = new OutputParserTokenManager(jj_input_stream);
- token = new Token();
- jj_ntk = -1;
- jj_gen = 0;
- for (int i = 0; i < 0; 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) {
- jj_input_stream.ReInit(stream, 1, 1);
- token_source.ReInit(jj_input_stream);
- token = new Token();
- jj_ntk = -1;
- jj_gen = 0;
- for (int i = 0; i < 0; 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 OutputParser(OutputParserTokenManager tm) {
- token_source = tm;
- token = new Token();
- jj_ntk = -1;
- jj_gen = 0;
- for (int i = 0; i < 0; 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(OutputParserTokenManager tm) {
- token_source = tm;
- token = new Token();
- jj_ntk = -1;
- jj_gen = 0;
- for (int i = 0; i < 0; 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();
- }
-
- 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() {
- 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<int[]> jj_expentries = new java.util.ArrayList<int[]>();
- 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];
- }
- jj_entries_loop: for (java.util.Iterator<?> it = jj_expentries.iterator(); it.hasNext();) {
- int[] oldentry = (int[])(it.next());
- if (oldentry.length == jj_expentry.length) {
- for (int i = 0; i < jj_expentry.length; i++) {
- if (oldentry[i] != jj_expentry[i]) {
- continue jj_entries_loop;
- }
- }
- jj_expentries.add(jj_expentry);
- break jj_entries_loop;
- }
- }
- if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
- }
- }
-
- /** Generate ParseException. */
- public ParseException generateParseException() {
- jj_expentries.clear();
- boolean[] la1tokens = new boolean[6];
- if (jj_kind >= 0) {
- la1tokens[jj_kind] = true;
- jj_kind = -1;
- }
- for (int i = 0; i < 0; i++) {
- if (jj_la1[i] == jj_gen) {
- for (int j = 0; j < 32; j++) {
- if ((jj_la1_0[i] & (1<<j)) != 0) {
- la1tokens[j] = true;
- }
- }
- }
- }
- for (int i = 0; i < 6; i++) {
- if (la1tokens[i]) {
- jj_expentry = new int[1];
- jj_expentry[0] = i;
- jj_expentries.add(jj_expentry);
- }
- }
- jj_endpos = 0;
- jj_rescan_token();
- jj_add_error_token(0, 0);
- int[][] exptokseq = new int[jj_expentries.size()][];
- for (int i = 0; i < jj_expentries.size(); i++) {
- exptokseq[i] = jj_expentries.get(i);
- }
- return new ParseException(token, exptokseq, tokenImage);
- }
-
- /** Enable tracing. */
- final public void enable_tracing() {
- }
-
- /** Disable tracing. */
- final public void disable_tracing() {
- }
-
- private void jj_rescan_token() {
- jj_rescan = true;
- for (int i = 0; i < 14; i++) {
- try {
- JJCalls p = jj_2_rtns[i];
- do {
- if (p.gen > 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;
- case 2: jj_3_3(); break;
- case 3: jj_3_4(); break;
- case 4: jj_3_5(); break;
- case 5: jj_3_6(); break;
- case 6: jj_3_7(); break;
- case 7: jj_3_8(); break;
- case 8: jj_3_9(); break;
- case 9: jj_3_10(); break;
- case 10: jj_3_11(); break;
- case 11: jj_3_12(); break;
- case 12: jj_3_13(); break;
- case 13: jj_3_14(); 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;
- }
-
-}
+/* Generated By:JavaCC: Do not edit this line. OutputParser.java */
+package net.sf.eclipsefp.haskell.hlint.parser;
+
+import java.util.*;
+import net.sf.eclipsefp.haskell.hlint.*;
+
+public class OutputParser implements OutputParserConstants {
+
+ final public List<Suggestion> suggestions() throws ParseException {
+ ArrayList<Suggestion > sugs= new ArrayList<Suggestion>();
+ Suggestion sug;
+ label_1:
+ while (true) {
+ if (jj_2_1(3)) {
+ ;
+ } else {
+ break label_1;
+ }
+ sug = suggestion();
+ sugs.add(sug);
+ }
+ jj_consume_token(INTEGER);
+ string_until_eol();
+ jj_consume_token(0);
+ {if (true) return sugs;}
+ throw new Error("Missing return statement in function");
+ }
+
+ final public Suggestion suggestion() throws ParseException {
+ StringBuilder filename;
+ Integer line;
+ Integer column;
+ Severity sev;
+ StringBuilder message;
+ CodeModification pre;
+ CodeModification post;
+ filename = filename();
+ line = number();
+ column = number();
+ jj_consume_token(SPACE);
+ sev = severity();
+ jj_consume_token(SPACE);
+ message = string_until_eol();
+ pre = code_mod();
+ post = code_mod();
+ jj_consume_token(EOL);
+ Suggestion s = new Suggestion();
+ s.setLocation(new SourceLocation(filename.toString().replace("\u005c\u005c\u005c\u005c","\u005c\u005c"), line, column));
+ s.setSeverity(sev);
+ s.setMessage(message.toString());
+ s.setPre(pre);
+ s.setPost(post);
+ {if (true) return s;}
+ throw new Error("Missing return statement in function");
+ }
+
+ final public StringBuilder filename() throws ParseException {
+ Token c;
+ StringBuilder s=new StringBuilder();
+ StringBuilder rest=new StringBuilder();
+ if (jj_2_2(3)) {
+ c = jj_consume_token(COLON_SLASH);
+ s.append(c.image);
+ } else if (jj_2_3(3)) {
+ c = jj_consume_token(OTHER_CHAR);
+ s.append(c.image);
+ } else if (jj_2_4(3)) {
+ c = jj_consume_token(SPACE);
+ s.append(c.image);
+ } else {
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ rest = string_until_colon();
+ s.append(rest);
+ {if (true) return s;}
+ throw new Error("Missing return statement in function");
+ }
+
+ final public StringBuilder string_until_colon() throws ParseException {
+ Token c;
+ Token c1, c2;
+ StringBuilder s=new StringBuilder();
+ label_2:
+ while (true) {
+ if (jj_2_5(3)) {
+ ;
+ } else {
+ break label_2;
+ }
+ if (jj_2_6(3)) {
+ c = jj_consume_token(COLON_SLASH);
+ s.append(c.image);
+ } else if (jj_2_7(3)) {
+ c = jj_consume_token(OTHER_CHAR);
+ s.append(c.image);
+ } else if (jj_2_8(3)) {
+ c = jj_consume_token(SPACE);
+ s.append(c.image);
+ } else if (jj_2_9(3)) {
+ c = jj_consume_token(INTEGER);
+ s.append(c.image);
+ } else {
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ jj_consume_token(COLON);
+ {if (true) return s;}
+ throw new Error("Missing return statement in function");
+ }
+
+/*{
+ c = < OTHER_CHAR >
+ s = string_until_colon()
+ {
+ s.insert(0, c.image);
+ return s;
+ }
+| c = < INTEGER >
+ s = string_until_colon()
+ {
+ s.insert(0, c.image);
+ return s;
+ }
+| c = < SPACE >
+ s = string_until_colon()
+ {
+ s.insert(0, c.image);
+ return s;
+ }
+| c = < COLON_SLASH >
+ s = string_until_colon()
+ {
+ s.insert(0, c.image);
+ return s;
+ }
+| < COLON >
+ {
+ return new StringBuilder();
+ }
+}*/
+ final public StringBuilder string_until_eol() throws ParseException {
+ Token c;
+ StringBuilder s=new StringBuilder();
+ label_3:
+ while (true) {
+ if (jj_2_10(3)) {
+ ;
+ } else {
+ break label_3;
+ }
+ if (jj_2_11(3)) {
+ c = jj_consume_token(COLON_SLASH);
+ s.append(c.image);
+ } else if (jj_2_12(3)) {
+ c = jj_consume_token(OTHER_CHAR);
+ s.append(c.image);
+ } else if (jj_2_13(3)) {
+ c = jj_consume_token(COLON);
+ s.append(c.image);
+ } else if (jj_2_14(3)) {
+ c = jj_consume_token(SPACE);
+ s.append(c.image);
+ } else if (jj_2_15(3)) {
+ c = jj_consume_token(INTEGER);
+ s.append(c.image);
+ } else {
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ jj_consume_token(EOL);
+ {if (true) return s;}
+ throw new Error("Missing return statement in function");
+ }
+
+/*{
+ c = < OTHER_CHAR >
+ s = string_until_eol()
+ {
+ s.insert(0, c.image);
+ return s;
+ }
+| c = < SPACE >
+ s = string_until_eol()
+ {
+ s.insert(0, c.image);
+ return s;
+ }
+| c = < COLON_SLASH >
+ s = string_until_eol()
+ {
+ s.insert(0, c.image);
+ return s;
+ }
+| c = < COLON >
+ s = string_until_eol()
+ {
+ s.insert(0, c.image);
+ return s;
+ }
+| < EOL >
+ {
+ return new StringBuilder();
+ }
+}*/
+ final public Integer number() throws ParseException {
+ Token c;
+ c = jj_consume_token(INTEGER);
+ jj_consume_token(COLON);
+ {if (true) return Integer.valueOf(c.image);}
+ throw new Error("Missing return statement in function");
+ }
+
+ final public Severity severity() throws ParseException {
+ StringBuilder sb;
+ sb = string_until_colon();
+ String s = sb.toString();
+ if (s.equals("Ignore"))
+ {if (true) return Severity.IGNORE;}
+ else if (s.equals("Warning"))
+ {if (true) return Severity.WARNING;}
+ else if (s.equals("Error"))
+ {if (true) return Severity.ERROR;}
+ else
+ {if (true) return null;}
+ throw new Error("Missing return statement in function");
+ }
+
+ final public CodeModification code_mod() throws ParseException {
+ StringBuilder s;
+ string_until_eol();
+ s = null;
+ if (jj_2_16(3)) {
+ s = source_code();
+ } else {
+ ;
+ }
+ if (s != null)
+ {if (true) return new CodeModificationText(s.toString());}
+ else
+ {if (true) return new CodeModificationRemove();}
+ throw new Error("Missing return statement in function");
+ }
+
+ final public StringBuilder source_code_line() throws ParseException {
+ StringBuilder line;
+ jj_consume_token(SPACE);
+ jj_consume_token(SPACE);
+ line = string_until_eol();
+ {if (true) return line;}
+ throw new Error("Missing return statement in function");
+ }
+
+ final public StringBuilder source_code() throws ParseException {
+ StringBuilder line;
+ StringBuilder all;
+ all = source_code_line();
+ label_4:
+ while (true) {
+ if (jj_2_17(3)) {
+ ;
+ } else {
+ break label_4;
+ }
+ line = source_code_line();
+ all.append('\u005cn');
+ all.append(line.toString());
+ }
+ {if (true) return all;}
+ 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_2_3(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_3(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(2, xla); }
+ }
+
+ private boolean jj_2_4(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_4(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(3, xla); }
+ }
+
+ private boolean jj_2_5(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_5(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(4, xla); }
+ }
+
+ private boolean jj_2_6(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_6(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(5, xla); }
+ }
+
+ private boolean jj_2_7(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_7(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(6, xla); }
+ }
+
+ private boolean jj_2_8(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_8(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(7, xla); }
+ }
+
+ private boolean jj_2_9(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_9(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(8, xla); }
+ }
+
+ private boolean jj_2_10(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_10(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(9, xla); }
+ }
+
+ private boolean jj_2_11(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_11(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(10, xla); }
+ }
+
+ private boolean jj_2_12(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_12(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(11, xla); }
+ }
+
+ private boolean jj_2_13(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_13(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(12, xla); }
+ }
+
+ private boolean jj_2_14(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_14(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(13, xla); }
+ }
+
+ private boolean jj_2_15(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_15(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(14, xla); }
+ }
+
+ private boolean jj_2_16(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_16(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(15, xla); }
+ }
+
+ private boolean jj_2_17(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_17(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(16, xla); }
+ }
+
+ private boolean jj_3R_6() {
+ if (jj_3R_7()) return true;
+ return false;
+ }
+
+ private boolean jj_3_6() {
+ if (jj_scan_token(COLON_SLASH)) return true;
+ return false;
+ }
+
+ private boolean jj_3_5() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_6()) {
+ jj_scanpos = xsp;
+ if (jj_3_7()) {
+ jj_scanpos = xsp;
+ if (jj_3_8()) {
+ jj_scanpos = xsp;
+ if (jj_3_9()) return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean jj_3R_11() {
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_5()) { jj_scanpos = xsp; break; }
+ }
+ if (jj_scan_token(COLON)) return true;
+ return false;
+ }
+
+ private boolean jj_3_15() {
+ if (jj_scan_token(INTEGER)) return true;
+ return false;
+ }
+
+ private boolean jj_3R_7() {
+ if (jj_scan_token(SPACE)) return true;
+ if (jj_scan_token(SPACE)) return true;
+ if (jj_3R_10()) return true;
+ return false;
+ }
+
+ private boolean jj_3R_9() {
+ if (jj_scan_token(INTEGER)) return true;
+ return false;
+ }
+
+ private boolean jj_3_14() {
+ if (jj_scan_token(SPACE)) return true;
+ return false;
+ }
+
+ private boolean jj_3_4() {
+ if (jj_scan_token(SPACE)) return true;
+ return false;
+ }
+
+ private boolean jj_3R_5() {
+ if (jj_3R_8()) return true;
+ if (jj_3R_9()) return true;
+ return false;
+ }
+
+ private boolean jj_3_13() {
+ if (jj_scan_token(COLON)) return true;
+ return false;
+ }
+
+ private boolean jj_3_12() {
+ if (jj_scan_token(OTHER_CHAR)) return true;
+ return false;
+ }
+
+ private boolean jj_3_16() {
+ if (jj_3R_6()) return true;
+ return false;
+ }
+
+ private boolean jj_3_3() {
+ if (jj_scan_token(OTHER_CHAR)) return true;
+ return false;
+ }
+
+ private boolean jj_3_9() {
+ if (jj_scan_token(INTEGER)) return true;
+ return false;
+ }
+
+ private boolean jj_3_8() {
+ if (jj_scan_token(SPACE)) return true;
+ return false;
+ }
+
+ private boolean jj_3_10() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_11()) {
+ jj_scanpos = xsp;
+ if (jj_3_12()) {
+ jj_scanpos = xsp;
+ if (jj_3_13()) {
+ jj_scanpos = xsp;
+ if (jj_3_14()) {
+ jj_scanpos = xsp;
+ if (jj_3_15()) return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean jj_3_11() {
+ if (jj_scan_token(COLON_SLASH)) return true;
+ return false;
+ }
+
+ private boolean jj_3R_10() {
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_10()) { jj_scanpos = xsp; break; }
+ }
+ if (jj_scan_token(EOL)) return true;
+ return false;
+ }
+
+ private boolean jj_3_2() {
+ if (jj_scan_token(COLON_SLASH)) return true;
+ return false;
+ }
+
+ private boolean jj_3_7() {
+ if (jj_scan_token(OTHER_CHAR)) return true;
+ return false;
+ }
+
+ private boolean jj_3R_8() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_2()) {
+ jj_scanpos = xsp;
+ if (jj_3_3()) {
+ jj_scanpos = xsp;
+ if (jj_3_4()) return true;
+ }
+ }
+ if (jj_3R_11()) return true;
+ return false;
+ }
+
+ private boolean jj_3_17() {
+ if (jj_3R_7()) return true;
+ return false;
+ }
+
+ private boolean jj_3_1() {
+ if (jj_3R_5()) return true;
+ return false;
+ }
+
+ /** Generated Token Manager. */
+ public OutputParserTokenManager 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[0];
+ static private int[] jj_la1_0;
+ static {
+ jj_la1_init_0();
+ }
+ private static void jj_la1_init_0() {
+ jj_la1_0 = new int[] {};
+ }
+ final private JJCalls[] jj_2_rtns = new JJCalls[17];
+ private boolean jj_rescan = false;
+ private int jj_gc = 0;
+
+ /** Constructor with InputStream. */
+ public OutputParser(java.io.InputStream stream) {
+ this(stream, null);
+ }
+ /** Constructor with InputStream and supplied encoding */
+ public OutputParser(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 OutputParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 0; 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 < 0; i++) jj_la1[i] = -1;
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+ }
+
+ /** Constructor. */
+ public OutputParser(java.io.Reader stream) {
+ jj_input_stream = new SimpleCharStream(stream, 1, 1);
+ token_source = new OutputParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 0; 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) {
+ jj_input_stream.ReInit(stream, 1, 1);
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 0; 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 OutputParser(OutputParserTokenManager tm) {
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 0; 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(OutputParserTokenManager tm) {
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 0; 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();
+ }
+
+ 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() {
+ 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<int[]> jj_expentries = new java.util.ArrayList<int[]>();
+ 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];
+ }
+ jj_entries_loop: for (java.util.Iterator<?> it = jj_expentries.iterator(); it.hasNext();) {
+ int[] oldentry = (int[])(it.next());
+ if (oldentry.length == jj_expentry.length) {
+ for (int i = 0; i < jj_expentry.length; i++) {
+ if (oldentry[i] != jj_expentry[i]) {
+ continue jj_entries_loop;
+ }
+ }
+ jj_expentries.add(jj_expentry);
+ break jj_entries_loop;
+ }
+ }
+ if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
+ }
+ }
+
+ /** Generate ParseException. */
+ public ParseException generateParseException() {
+ jj_expentries.clear();
+ boolean[] la1tokens = new boolean[7];
+ if (jj_kind >= 0) {
+ la1tokens[jj_kind] = true;
+ jj_kind = -1;
+ }
+ for (int i = 0; i < 0; i++) {
+ if (jj_la1[i] == jj_gen) {
+ for (int j = 0; j < 32; j++) {
+ if ((jj_la1_0[i] & (1<<j)) != 0) {
+ la1tokens[j] = true;
+ }
+ }
+ }
+ }
+ for (int i = 0; i < 7; i++) {
+ if (la1tokens[i]) {
+ jj_expentry = new int[1];
+ jj_expentry[0] = i;
+ jj_expentries.add(jj_expentry);
+ }
+ }
+ jj_endpos = 0;
+ jj_rescan_token();
+ jj_add_error_token(0, 0);
+ int[][] exptokseq = new int[jj_expentries.size()][];
+ for (int i = 0; i < jj_expentries.size(); i++) {
+ exptokseq[i] = jj_expentries.get(i);
+ }
+ return new ParseException(token, exptokseq, tokenImage);
+ }
+
+ /** Enable tracing. */
+ final public void enable_tracing() {
+ }
+
+ /** Disable tracing. */
+ final public void disable_tracing() {
+ }
+
+ private void jj_rescan_token() {
+ jj_rescan = true;
+ for (int i = 0; i < 17; i++) {
+ try {
+ JJCalls p = jj_2_rtns[i];
+ do {
+ if (p.gen > 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;
+ case 2: jj_3_3(); break;
+ case 3: jj_3_4(); break;
+ case 4: jj_3_5(); break;
+ case 5: jj_3_6(); break;
+ case 6: jj_3_7(); break;
+ case 7: jj_3_8(); break;
+ case 8: jj_3_9(); break;
+ case 9: jj_3_10(); break;
+ case 10: jj_3_11(); break;
+ case 11: jj_3_12(); break;
+ case 12: jj_3_13(); break;
+ case 13: jj_3_14(); break;
+ case 14: jj_3_15(); break;
+ case 15: jj_3_16(); break;
+ case 16: jj_3_17(); 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;
View
129 net.sf.eclipsefp.haskell.hlint/src/net/sf/eclipsefp/haskell/hlint/parser/OutputParser.jj
@@ -1,7 +1,7 @@
/**
* JavaCC template file created by SF JavaCC plugin 1.5.17+ wizard for JavaCC 1.5.0+
*/ options { JDK_VERSION = "1.5";
- LOOKAHEAD = 100;
+ LOOKAHEAD = 3;
FORCE_LA_CHECK = true; static = false; } PARSER_BEGIN(OutputParser) package net.sf.eclipsefp.haskell.hlint.parser;
import java.util.*;
@@ -13,25 +13,20 @@ TOKEN :
| < EOL : "\n" | "\r" | "\r\n" >
| < COLON : ":" >
| < COLON_SLASH : ":\\" | ":/" >
+| < INTEGER : (["0"-"9"])+ >
| < OTHER_CHAR : ~[ "\n", "\r", ":" ] >
+
}
List<Suggestion> suggestions() :
{
- ArrayList<Suggestion > sugs;
+ ArrayList<Suggestion > sugs= new ArrayList<Suggestion>();
Suggestion sug; }
-{ string_until_eol()
- < EOF >
- { return new ArrayList<Suggestion>();
- }
-| sug = suggestion()
- { sugs = new ArrayList<Suggestion>();
- sugs.add(sug);
- }
- ( sug = suggestion()
+{ ( sug = suggestion()
{ sugs.add(sug);
}
)*
+ < INTEGER >
string_until_eol()
< EOF >
{ return sugs;
@@ -44,7 +39,7 @@ List<Suggestion> suggestions() :
StringBuilder message;
CodeModification pre;
CodeModification post;
-} { filename = string_until_colon()
+} { filename = filename()
line = number()
column = number()
< SPACE >
@@ -54,23 +49,82 @@ List<Suggestion> suggestions() :
pre = code_mod()
post = code_mod()
< EOL > { Suggestion s = new Suggestion();
- s.setLocation(new SourceLocation(filename.toString(), line, column));
+ s.setLocation(new SourceLocation(filename.toString().replace("\\\\","\\"), line, column));
s.setSeverity(sev);
s.setMessage(message.toString());
s.setPre(pre);
s.setPost(post);
return s; } }
+StringBuilder filename():
+{
+ Token c;
+ StringBuilder s=new StringBuilder();
+ StringBuilder rest=new StringBuilder(); }
+{
+ ( (
+ c=< COLON_SLASH >
+ {
+ s.append(c.image);
+ }
+ )
+ | (
+ c=< OTHER_CHAR >
+ {
+ s.append(c.image);
+ })
+ | (
+ c=< SPACE >
+ {
+ s.append(c.image);
+ })
+ )
+ rest=string_until_colon()
+ { s.append(rest);
+ return s;
+ } }
+
+
StringBuilder string_until_colon() :
{ Token c;
Token c1, c2;
- StringBuilder s;
+ StringBuilder s=new StringBuilder();
}
{
+ (( c=< COLON_SLASH >
+ {
+ s.append(c.image); }
+ )
+ | (
+ c=< OTHER_CHAR >
+ {
+ s.append(c.image);
+ })
+ | (
+ c=< SPACE >
+ {
+ s.append(c.image);
+ })
+ | (
+ c=< INTEGER >
+ {
+ s.append(c.image);
+ })
+ )*
+ < COLON >
+ { return s;
+ } }
+/*{
c = < OTHER_CHAR > s = string_until_colon()
{ s.insert(0, c.image);
return s;
}
+| c = < INTEGER >
+ s = string_until_colon()
+ {
+ s.insert(0, c.image);
+ return s;
+ }
| c = < SPACE >
s = string_until_colon()
{
@@ -86,14 +140,46 @@ StringBuilder string_until_colon() :
| < COLON >
{ return new StringBuilder();
}
-}
+}*/
StringBuilder string_until_eol() :
{
Token c;
- StringBuilder s;
+ StringBuilder s=new StringBuilder();
}
-{
+{ ((
+ c=< COLON_SLASH >
+ {
+ s.append(c.image);
+ }
+ )
+ | (
+ c=< OTHER_CHAR >
+ {
+ s.append(c.image);
+ })
+ | (
+ c=< COLON >
+ {
+ s.append(c.image);
+ })
+ | (
+ c=< SPACE >
+ {
+ s.append(c.image);
+ })
+ | (
+ c=< INTEGER >
+ {
+ s.append(c.image);
+ })
+ )*
+ < EOL >
+ {
+ return s;
+ }
+}
+/*{
c = < OTHER_CHAR >
s = string_until_eol()
{
@@ -122,16 +208,17 @@ StringBuilder string_until_eol() :
{
return new StringBuilder();
}
-}
+}*/
Integer number() :
{
- StringBuilder sb;
+ Token c;
}
{
- sb = string_until_colon()
+ c = < INTEGER >
+ < COLON >
{
- return Integer.valueOf(sb.toString());
+ return Integer.valueOf(c.image);
}
}
View
5 ...ipsefp.haskell.hlint/src/net/sf/eclipsefp/haskell/hlint/parser/OutputParserConstants.java
@@ -19,7 +19,9 @@
/** RegularExpression Id. */
int COLON_SLASH = 4;
/** RegularExpression Id. */
- int OTHER_CHAR = 5;
+ int INTEGER = 5;
+ /** RegularExpression Id. */
+ int OTHER_CHAR = 6;
/** Lexical state. */
int DEFAULT = 0;
@@ -31,6 +33,7 @@
"<EOL>",
"\":\"",
"<COLON_SLASH>",
+ "<INTEGER>",
"<OTHER_CHAR>",
};
View
49 ...efp.haskell.hlint/src/net/sf/eclipsefp/haskell/hlint/parser/OutputParserTokenManager.java
@@ -36,7 +36,7 @@ private int jjMoveStringLiteralDfa0_0()
case 32:
return jjStopAtPos(0, 1);
case 58:
- return jjStartNfaWithStates_0(0, 3, 5);
+ return jjStartNfaWithStates_0(0, 3, 6);
default :
return jjMoveNfa_0(0, 0);
}
@@ -55,7 +55,7 @@ private int jjStartNfaWithStates_0(int pos, int kind, int state)
private int jjMoveNfa_0(int startState, int curPos)
{
int startsAt = 0;
- jjnewStateCnt = 7;
+ jjnewStateCnt = 8;
int i = 1;
jjstateSet[0] = startState;
int kind = 0x7fffffff;
@@ -73,8 +73,8 @@ private int jjMoveNfa_0(int startState, int curPos)
case 0:
if ((0xfbffffffffffdbffL & l) != 0L)
{
- if (kind > 5)
- kind = 5;
+ if (kind > 6)
+ kind = 6;
}
else if ((0x2400L & l) != 0L)
{
@@ -83,10 +83,16 @@ else if ((0x2400L & l) != 0L)
}
else if (curChar == 58)
jjAddStates(0, 1);
- if (curChar == 13)
+ if ((0x3ff000000000000L & l) != 0L)
+ {
+ if (kind > 5)
+ kind = 5;
+ jjCheckNAdd(3);
+ }
+ else if (curChar == 13)
jjstateSet[jjnewStateCnt++] = 1;
break;
- case 5:
+ case 6:
if (curChar == 47 && kind > 4)
kind = 4;
break;
@@ -99,10 +105,17 @@ else if (curChar == 58)
jjstateSet[jjnewStateCnt++] = 1;
break;
case 3:
- if ((0xfbffffffffffdbffL & l) != 0L && kind > 5)
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 5)
kind = 5;
+ jjCheckNAdd(3);
break;
case 4:
+ if ((0xfbffffffffffdbffL & l) != 0L && kind > 6)
+ kind = 6;
+ break;
+ case 5:
if (curChar == 58)
jjAddStates(0, 1);
break;
@@ -118,10 +131,10 @@ else if (curChar < 128)
switch(jjstateSet[--i])
{
case 0:
- if (kind > 5)
- kind = 5;
+ if (kind > 6)
+ kind = 6;
break;
- case 5:
+ case 6:
if (curChar == 92 && kind > 4)
kind = 4;
break;
@@ -138,8 +151,8 @@ else if (curChar < 128)
switch(jjstateSet[--i])
{
case 0:
- if ((jjbitVec0[i2] & l2) != 0L && kind > 5)
- kind = 5;
+ if ((jjbitVec0[i2] & l2) != 0L && kind > 6)
+ kind = 6;
break;
default : break;
}
@@ -152,27 +165,27 @@ else if (curChar < 128)
kind = 0x7fffffff;
}
++curPos;
- if ((i = jjnewStateCnt) == (startsAt = 7 - (jjnewStateCnt = startsAt)))
+ if ((i = jjnewStateCnt) == (startsAt = 8 - (jjnewStateCnt = startsAt)))
return curPos;
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return curPos; }
}
}
static final int[] jjnextStates = {
- 5, 6,
+ 6, 7,
};
/** Token literal values. */
public static final String[] jjstrLiteralImages = {
-"", "\40", null, "\72", null, null, };
+"", "\40", null, "\72", null, null, null, };
/** Lexer state names. */
public static final String[] lexStateNames = {
"DEFAULT",
};
protected SimpleCharStream input_stream;
-private final int[] jjrounds = new int[7];
-private final int[] jjstateSet = new int[14];
+private final int[] jjrounds = new int[8];
+private final int[] jjstateSet = new int[16];
protected char curChar;
/** Constructor. */
public OutputParserTokenManager(SimpleCharStream stream){
@@ -199,7 +212,7 @@ private void ReInitRounds()
{
int i;
jjround = 0x80000001;
- for (i = 7; i-- > 0;)
+ for (i = 8; i-- > 0;)
jjrounds[i] = 0x80000000;
}
View
2  net.sf.eclipsefp.haskell.hlint/src/net/sf/eclipsefp/haskell/hlint/parser/ParseException.java
@@ -184,4 +184,4 @@ static String add_escapes(String str) {
}
}
-/* JavaCC - OriginalChecksum=ffd5aa5f6066e54d5d459c8a6133b032 (do not edit this line) */
+/* JavaCC - OriginalChecksum=b90aae9288654495d4fdacadd1119635 (do not edit this line) */
View
2  ...f.eclipsefp.haskell.hlint/src/net/sf/eclipsefp/haskell/hlint/parser/SimpleCharStream.java
@@ -468,4 +468,4 @@ public void adjustBeginLineColumn(int newLine, int newCol)
}
}
-/* JavaCC - OriginalChecksum=b20f0253d280f64cbcefd218f58fa29d (do not edit this line) */
+/* JavaCC - OriginalChecksum=58e00cc5d844593e39638c629401c03b (do not edit this line) */
View
2  net.sf.eclipsefp.haskell.hlint/src/net/sf/eclipsefp/haskell/hlint/parser/Token.java
@@ -128,4 +128,4 @@ public static Token newToken(int ofKind)
}
}
-/* JavaCC - OriginalChecksum=f55c79a1895ff9c17a897f8bac12e1be (do not edit this line) */
+/* JavaCC - OriginalChecksum=8f31af2ccb016e2d3dd55620b75d41ba (do not edit this line) */
View
2  net.sf.eclipsefp.haskell.hlint/src/net/sf/eclipsefp/haskell/hlint/parser/TokenMgrError.java
@@ -144,4 +144,4 @@ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColu
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
}
}
-/* JavaCC - OriginalChecksum=b8cbc85a8c7e83bb570cec426015b752 (do not edit this line) */
+/* JavaCC - OriginalChecksum=f2de9dedca658d9b3abf943fd6b06406 (do not edit this line) */
Please sign in to comment.
Something went wrong with that request. Please try again.