diff --git a/README.html b/README.html index 13dfcd27..6fc151f2 100644 --- a/README.html +++ b/README.html @@ -37,11 +37,13 @@ Freely available under the terms of the · luaj api · -building +parser · -downloads +building · -release notes +downloads +· +release notes
@@ -348,7 +350,7 @@ that are needed and omitting the line: -
To compile from lua sources to Java sources for all lua loaded at runtime, @@ -361,7 +363,7 @@ install the Lua2Java compiler after globals have been created using: This uses the system Java compiler to compile from Java source to Java bytecode, and cannot compile lua binary files containing lua bytecode at runtime. -
To compile from lua to Java bytecode for all lua loaded at runtime, @@ -376,7 +378,7 @@ This will compile all lua bytecode into Java bytecode, regardless of if they are lua source or lua binary files.
-The bcel library must be on the class path for this to work. +The requires bcel to be on the class path, and the ClassLoader of JSE or CDC.
+A plain undecorated grammer that can be used for validation is available in grammar/Lua51.jj +while a grammar that generates a typed parse tree is in grammar/LuaParser.jj + +
+To simplify the creation of abstract syntax trees from lua sources, the LuaParser class is generated as part of the JME build. +To use it, provide an input stream, and invoke the root generator, which will return a Chunk if the file is valid, +or throw a ParseException if there is a syntax error. + +
+For example, to parse a file and print all variable names, use code like: +
+ try {
+ String file = "main.lua";
+ LuaParser parser = new LuaParser(new FileInputStream(file));
+ Chunk chunk = parser.Chunk();
+ chunk.accept( new Visitor() {
+ public void visit(Exp.NameExp exp) {
+ System.out.println("Name in use: "+exp.name.name);
+ }
+ } );
+ } catch ( ParseException e ) {
+ System.out.println( "parse failed: "+e );
+ }
+
+
++See the org.luaj.vm2.ast package javadoc for the API relating to the syntax tree that is produced. + +