leastfixedpoint / java-parser-tools Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/java-parser-tools
Automatically exported from code.google.com/p/java-parser-tools
I have been ponering how to define quoted string in my Turtle grammar
definition. Currently I have this (which is not sufficient)...
quotedString ::= ("'"" {anychar} "'"")
anychar ::= (%alpha% | %digit% | " " | ":" | ".")
What I really need is a quoted string matcher like the one defined in the
info.reflectionsofmind.parser.Grammar class.
However, in order to be able to use a custom Matcher I would have to
abandon my grammar defintion file and instead define the Turtle grammar in
Java, using the info.reflectionsofmind.parser API.
However, if an extension syntax is added to the grammar definition then it
would be possible to create Matchers in Java and refer to them in the
grammer.
There is an example of EBNF extension syntax in this article...
http://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form
Basically, in java-parser-ttols, the extension syntax would allow a
Matcher defined in Java to be assigned to a named matcher in the grammar
definitionwork. Here is an example...
quotedString= ?info.reflectionsofmind.parser.QuotedStringMatcher?
...where the contents between the question marks names a class that
implements a Matcher.
Original issue reported on code.google.com by emorning
on 14 Apr 2009 at 6:08
It would be convenient if the Grammar class supported %whitespace% in
grammar files.
Original issue reported on code.google.com by emorning
on 7 Apr 2009 at 7:39
Current if you pass an expression name into the Grammar.generate method
that does not exist in the given grammer then Grammar.generate will simply
return a null Matcher.
It would be nicer if it threw an exception intead.
Original issue reported on code.google.com by emorning
on 7 Apr 2009 at 6:22
XPath support (possibly using Jaxen) would make it much easier to navigate
an AST.
For instance, given this grammar...
turtleDocument ::= {statement {%whitespace%}}
statement ::= ((directive {%whitespace%} ".") | (triples {%
whitespace%} "."))
directive ::= (prefixID | base)
prefixID ::= ("@prefix" %whitespace% [prefixName] ":" {%whitespace%}
uriref)
base ::= ("@base" %whitespace% uriref)
I have to navigate down 6 levels of to get to a 'base' node.
With XPath I could just do...
NamedNode base= XPath.selectNode("//base");
Original issue reported on code.google.com by emorning
on 8 Apr 2009 at 1:53
Adding getParent() to Abstract node will make it easier to navigate node
trees.
Consider the following grammar...
predicateObjectList ::= (verb objectList {";" verb objectList})
objectList ::= (object {"," object})
verb ::= (resource | "a")
Then consider the task of processing the verbs and associated objects in a
predicateObjectList.
We can first get the all the verb nodes..
List<AbstractNode> verbNodes= Navigation.findAllDecendentsById
(predicateObjectListNode, "verb");
Now, given a verb node how can we get the associated object nodes?
There currently is no easy way except to manually navigate the
predicateObjectList node and process the verbs and objects are we
encounter them, yuck.
If we add getParent() to the AbstractNode class then we can easily find
all the objects nodes for verb like so...
List<AbstractNode> objectNodes= Navigation.findAllDecendentsById
(verbNode.getParent(), "object");
Original issue reported on code.google.com by emorning
on 9 Apr 2009 at 10:27
My grammer is shown below.
Notice that the definition of the 'statement' expression includes a
reference to the 'comment' expression. However, the 'comment' expression
is not defined.
Later, when the Matchers.fullMatch method is called a NullPointer
exception is thrown.
Matchers.fullMatch(matcher, "@prefix
bindingType:<meteor:net.sf.meteor.BindingType>.");
-----------------------------------------
My grammer...
turtleDocument ::= {statement {whitespace}}
statement ::= ((directive {whitespace} ".") | (triples {whitespace} ".") |
comment)
directive ::= (prefixID | base)
prefixID ::= ("@prefix" whitespace [prefixName] ":" {whitespace} uriref)
base ::= ("@base" whitespace uriref)
triples ::= (subject predicateObjectList)
predicateObjectList ::= (verb objectList ";" {verb objectList ";"})
objectList ::= (object {"," object})
verb ::= (resource | "a")
subject ::= (resource | blank)
object ::= (resource | blank | literal)
literal ::= (quotedString (["@" language] | datatypeString | integer |
double | decimal | boolean))
datatypeString ::= (quotedString "^^" resource)
digits ::= (%digit% {%digit%})
sign ::= ("-" | "+")
integer ::= ([sign] digits)
doubl ::= ([sign] ((digits "." [digits] exponent) | ("." digits exponent)
| (digits exponent)))
decimal ::= ([sign] ((digits "." {digits}) | ("." digits) | digits))
exponent ::= (["e" | "E"] [sign] digits)
boolean ::= ("true" | "false")
blank ::= (nodeID | "[]" | ("[" predicateObjectList "]") | collection)
collection ::= ("(" (object {"," object}) ")")
resource ::= (uriref | qname)
nodeID ::= ("_:" name)
qname ::= ([prefixName] ":" [name])
uriref ::= ("<" relativeURI ">")
language ::= ((%lower% {%lower%}) {"-" ((%lower% | %digit%) {(%lower% | %
digit%)})})
nameStartChar ::= (%alpha% | "_")
nameChar ::= (%alpha% | %digit% | "-")
name ::= (nameStartChar {nameChar})
prefixName ::= (nameStartChar {nameChar})
relativeURI ::= (anychar {anychar})
quotedString ::= ("$" {anychar} "$")
anychar ::= (%alpha% | %digit% | " " | ":" | ".")
whitespace ::= (" " {" "})
Original issue reported on code.google.com by emorning
on 7 Apr 2009 at 6:49
Currently when a call is made to the Matchers.fullMatch(matcher, document)
method and a document is passed with a syntax error in it then fullMatch
simply returns an empty Results list.
There needs to be a way to indicate where the parsing failed so that the
syntax error may be discovered.
Perhaps the returned List should always have at least one Result object
and the Result class should contain fields to indicate if a matching error
happened and where in the document matching failed.
Original issue reported on code.google.com by emorning
on 7 Apr 2009 at 7:56
I need to define 'quoted strings' in my grammer.
Something like this...
quotedString ::= ("\"" {anychar} "\"")
I looked around at how other ebnf syntaxes handle this.
I can think of two ways to handle this.
1) Allow either single quotes or double quotes when defining text.
This is what the 'official' EBNF specification does.
http://www.cl.cam.ac.uk/~mgk25/iso-14977.pdf
2) Use backslash as an escape character like I did above.
This approach would be familiar to Java programmers.
I chose appoach #1 since it is easily implemented by changing java-parsing-
tools grammer definition.
Original issue reported on code.google.com by emorning
on 13 Apr 2009 at 9:07
To allow for better i18n, recognizing of different error types and overall
static code verification we should store an Exception, not a String to
indicate matching failure.
Original issue reported on code.google.com by [email protected]
on 22 Sep 2009 at 9:28
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.