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: -

Including the lua-source-to-Java-source compiler

+

Including the Lua2Java lua-source-to-Java-source compiler

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. -

Including the lua-bytecode-to-Java-bytecode compiler

+

Including the LuaJC lua-bytecode-to-Java-bytecode compiler

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.

3 - Concepts

@@ -605,7 +607,46 @@ To allow for arguments, or return multiple values, extend one of the other base

Closures

Closures still exist in this framework, but are optional, and are only used to implement lua bytecode execution. -

6 - Building and Testing

+

6 - Parser

+ +

Javacc Grammar

+A Javacc grammarwas developed to simplify the creation of Java-based parsers for the lua language. +The grammar is specified for javacc version 5.0 because that tool generates standalone +parsers that do not require a separate runtime. + +

+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 + +

Creating a Parse Tree from Lua Source

+The default lu compiler does a single-pass compile of lua source to lua bytecode, so no explicit parse tree is produced. + +

+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. + +

7 - Building and Testing

Building the jars

An ant file is included in the root directory which builds the libraries by default. @@ -640,7 +681,7 @@ A build script for running unit tests and producing code coverage statistics is It relies on the cobertura code coverage library. -

7 - Downloads

+

8 - Downloads

Downloads and Project Pages

Downloads for version 1.0.3 are currently hosted on SourceForge. @@ -658,7 +699,7 @@ and LuaForge: LuaForge Luaj Project Area -

8 - Release Notes

+

9 - Release Notes

Main Changes by Version