|
Post by cazanova on May 14, 2013 11:36:43 GMT -5
i'm trying to write a compiler code that read file of C++ code and check the Error's inside it . I need better Idea than what I Do . to check errors . .. just simple example for idea no more .
public void Myfun1() { JFileChooser chooser = new JFileChooser(); chooser.showOpenDialog(null); File f =chooser.getSelectedFile(); String filename=f.getAbsolutePath(); BufferedReader br; try { br = new BufferedReader(new FileReader(filename)); String line; while ((line = br.readLine()) != null) { String[]sytanxError={"int" ,"float", "double" , "cin" , "cout"}; for(int i=0;i < sytanxError;++i) { if(line.equals(sytanxError)) {
{
} } } br.close();
}
catch (FileNotFoundException ex) { Logger.getLogger(guiconcept.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(guiconcept.class.getName()).log(Level.SEVERE, null, ex); }
|
|
|
Post by cazanova on May 15, 2013 6:41:19 GMT -5
I found another way that I will do to define more errors and make lexical analysis by parsing generator . I will define my grammar and call it in my class . I'm reading how exactly compiler works so I can do it . hopefully it will work out .
|
|
|
Post by limber on May 15, 2013 7:37:20 GMT -5
I found another way that I will do to define more errors and make lexical analysis by parsing generator . I will define my grammar and call it in my class . I'm reading how exactly compiler works so I can do it . hopefully it will work out . That's better. Look up en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form for an easy way to define grammar. I've used it to write small compilers for logical relations.
|
|
|
Post by cazanova on May 15, 2013 12:11:54 GMT -5
I found another way that I will do to define more errors and make lexical analysis by parsing generator . I will define my grammar and call it in my class . I'm reading how exactly compiler works so I can do it . hopefully it will work out . That's better. Look up en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form for an easy way to define grammar. I've used it to write small compilers for logical relations. Thank you for your reply . I will do thank you for information
|
|