I am currently working on a project which needs to compile files and give a diagnostic of the errors(syntax) found. I have been able to get the program working for .java files. Now I have to do the same thing for files other than .java (example: .py files) and integrate it with my current program. I done some research and I've found that eclipse can support over 20 languages and the plugins are available for download. What I don't know is whether I can call the "compiler"(example for python) and get the diagnostics of the syntax errors found in the .py file. Should I look for the bnf for the language?
-
I think what you should google is to how to execute commands in console. http://java.ittoolbox.com/groups/technical-functional/java-l/how-to-execute-commands-in-console-1478515 – dinesh707 Feb 01 '13 at 09:34
2 Answers
If I have understood you correctly what you want is to compile python code from "inside" your Java program.
If that is the case, a quick response might be to launch the compiler using the Runtime Java class.
There is a nice answer here: getting output from executing a command line program
If what you want is to run the compiler from eclipse, as you have already been told PyDev is a good option.
Besides you can configure any external tool in eclipse this way, this is an example of configuring the command line for a windows system:
To enjoy a command line console inside eclipse just follow these steps:
- Goto Menu Run->External Tools->External Tools…
- Select Program in the “Configurations” (left) column
- Press New button (or right click -> new)
- In the Name edit box enter a name for this tool (this name will appear in the Run->External Tools menu)
- In the location add C:\WINNT\system32\cmd.exe *
- In the workspace directory add ${resource_loc}
- Press Close button

- 1
- 1

- 345
- 1
- 9
Surely you can. I am using PyDev, it does everything (syntax highlight, debugging, even some refactoring), and you need as little as to highlight syntax errors. There is no need to run command line tools manually when developing in Python under Eclipse.

- 20,936
- 12
- 75
- 93
-
My program needs to take a python file (most likely one that contains syntax errors) as input and then print the syntax errors on console. I need to do some processing with the errors that's why i need a way to get them printed out.Take at a segment of the code where i call the compiler: CompilationTask task = compiler.getTask(null, fileManager, listener, null, null, fileObjects); Boolean result = task.call(); – user2026254 Feb 01 '13 at 09:43
-
I don't know if it is possible to call the compiler for python from a java program. I've been told that a "bnf for python" will help. – user2026254 Feb 01 '13 at 09:52
-
You can look into Eclipse builder under Project settings then. A builder can be any program that runs during the build and can produce the custom output like error log. You can configure builders to run when you change particular folder or particular file. However in general using GUI for getting list of errors in the file seems overkill. – Audrius Meškauskas Feb 01 '13 at 09:53