1 9 10 package org.netbeans.modules.languages.parser; 11 12 import org.netbeans.api.languages.ParseException; 13 import org.netbeans.modules.languages.parser.TokenInput; 14 import org.netbeans.api.languages.ASTNode; 15 import java.io.BufferedReader ; 16 import java.io.IOException ; 17 import java.io.InputStream ; 18 import java.io.InputStreamReader ; 19 import java.util.List ; 20 import java.util.Map ; 21 import junit.framework.TestCase; 22 import org.netbeans.modules.languages.Language; 23 import org.netbeans.modules.languages.NBSLanguageReader; 24 25 26 30 public class NBSTest extends TestCase { 31 32 public NBSTest (String testName) { 33 super (testName); 34 } 35 36 public void testFirst () { 37 InputStream is = getClass ().getClassLoader ().getResourceAsStream ("org/netbeans/modules/languages/resources/NBS.nbs"); 38 try { 39 Language l = NBSLanguageReader.readLanguage ("test", is, "test/x-nbs"); 40 List r = l.getAnalyser ().getRules (); 41 Map f = Petra.first2 (r); 44 assertFalse (AnalyserAnalyser.hasConflicts (f)); 48 } catch (ParseException ex) { 49 ex.printStackTrace(); 50 } catch (IOException ex) { 51 ex.printStackTrace(); 52 } 53 } 54 55 public void test2 () throws ParseException, IOException { 56 InputStream is = getClass ().getClassLoader ().getResourceAsStream ("org/netbeans/modules/languages/resources/NBS.nbs"); 57 Language l = NBSLanguageReader.readLanguage ("test", is, "test/x-nbs"); 58 59 is = getClass ().getClassLoader ().getResourceAsStream ("org/netbeans/modules/languages/resources/NBS.nbs"); 60 BufferedReader br = new BufferedReader (new InputStreamReader (is)); 61 StringBuilder sb = new StringBuilder (); 62 String ln = br.readLine (); 63 while (ln != null) { 64 sb.append (ln).append ('\n'); 65 ln = br.readLine (); 66 } 67 TokenInput ti = TokenInput.create ( 68 "text/test", 69 l.getParser (), 70 new StringInput (sb.toString (), "NBS.nbs"), 71 l.getSkipTokenTypes () 72 ); 73 ASTNode n = l.getAnalyser ().read (ti, false); 74 assertNotNull (n); 75 } 76 } 77 | Popular Tags |