From 2c748e0d3b1881d00329f28fe466713a9b8ff75c Mon Sep 17 00:00:00 2001 From: James Roseborough Date: Sat, 1 Sep 2012 17:07:23 +0000 Subject: [PATCH] Add line and column info to org.luaj.vm2.ast parse tree elements generated using LuaParser --- README.html | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/README.html b/README.html index 4ccb1dc2..097a0848 100644 --- a/README.html +++ b/README.html @@ -675,14 +675,23 @@ For example, to parse a file and print all variable names, use code like: Chunk chunk = parser.Chunk(); chunk.accept( new Visitor() { public void visit(Exp.NameExp exp) { - System.out.println("Name in use: "+exp.name.name); + System.out.println("Name in use: "+exp.name.name + +" line "+exp.beginLine + +" col "+exp.beginColumn); } } ); } catch ( ParseException e ) { - System.out.println( "parse failed: "+e ); + System.out.println( "parse failed: "+e + +" line "+e.currentToken.beginLine + +" col "+e.currentToken.beginColumn); } +An example that prints locations of all function definitions in a file may be found in +
+	examples/jse/SampleParser.java
+
+

See the org.luaj.vm2.ast package javadoc for the API relating to the syntax tree that is produced. @@ -764,6 +773,7 @@ and LuaForge:

  • Add arithmetic metatag processing when left hand side is a number and right hand side has metatable
  • Fix load(func) when mutiple string fragments are supplied by calls to func
  • Allow access to public members of private inner classes where possible
  • +
  • Add line and column info to org.luaj.vm2.ast parse tree elements generated using LuaParser