I am working on a school project where I need to generate Java code that adheres to the Java Language Specs. So far I have been able to generate the Java code randomly which has valid syntax that doesn't follow the language rules.
Next, I must be able to check if the language rules are obeyed by the generated code. What would be the best approach to follow this? Should I write code that checks if the language rules are adhered to? Is there an API available(Prolog?) that allows me to encode these rules and apply them to the code?
I don't think I can use the Java compiler API since it defeats the purpose of the homework. How would you approach this objective?
EDIT: The project doesn't require me to consider the entire Java Language Specs. I can consider a subset of the rules.