reverting the two files that should not have been committed in r337

This commit is contained in:
Inderjeet Singh 2008-12-18 23:42:44 +00:00
parent 6dbdb272c0
commit 40cf34a4cd
2 changed files with 2 additions and 238 deletions

View File

@ -1,236 +0,0 @@
/**
* Adapted from the Json parser grammar from http://code.google.com/p/jsonparser/
*
* Author: Inderjeet Singh
*/
options {
STATIC = false;
UNICODE_INPUT = true;
}
PARSER_BEGIN(JsonParser)
package com.google.gson;
@SuppressWarnings("all")
final class JsonParser {
}
PARSER_END(JsonParser)
SKIP : { " " | "\t" | "\n" | "\r" }
/*
* Technically Json does not allow leading zeros in numbers, but we
* will allow that.
*/
TOKEN : {
<E : ["e","E"](["+","-"])?>
| <DIGITS : (["0"-"9"])+>
| <NULL : "null">
| <NAN : "NaN">
| <BOOLEAN : ("true" | "false")>
| <IDENTIFIER : ["a"-"z","A"-"Z", "_"] (["a"-"z","A"-"Z","0"-"9","_"])* >
| <#HEX_CHAR : ["a"-"f","A"-"F","0"-"9"]>
| <UNICODE_CHAR : "\\u" <HEX_CHAR><HEX_CHAR><HEX_CHAR><HEX_CHAR> >
| <#ESCAPE_CHAR: "\\" ["n","t","b","r","f","\\","'","\"", "/"] >
| <SINGLE_QUOTE_LITERAL: "\'" ( (~["\'","\\","\n","\r"]) | <ESCAPE_CHAR> | <UNICODE_CHAR>)* "\'" >
| <DOUBLE_QUOTE_LITERAL: "\"" ( (~["\"","\\","\n","\r"]) | <ESCAPE_CHAR> | <UNICODE_CHAR>)* "\"" >
| <QUOTE : "\""> : STRING_STATE
}
<STRING_STATE> MORE : { "\\" : ESC_STATE }
<STRING_STATE> TOKEN : {
<ENDQUOTE : <QUOTE> > : DEFAULT
| <CHAR : ~["\"","\\"]>
}
<ESC_STATE> TOKEN : {
<CNTRL_ESC : ["\"","\\","/","b","f","n","r","t"]> : STRING_STATE
}
<ESC_STATE> MORE : { "u" : HEX_STATE }
<HEX_STATE> TOKEN : {
<#HEX : ["a"-"f","A"-"F","0"-"9"]>
| <HEX_ESC : <HEX><HEX><HEX><HEX> > : STRING_STATE
}
public JsonElement parse() :
{
JsonElement json = null;
}
{
( json=JsonObject() |
json=JsonArray() |
json=JsonPrimitive() |
json=JsonNull())
{ return json; }
}
private JsonObject JsonObject() :
{
JsonObject o = new JsonObject();
}
{
"{" [ Members(o) ] "}"
{ return o; }
}
private JsonNull JsonNull() :
{
Token t;
}
{
t = <NULL> { return new JsonNull(); }
}
private void Members(JsonObject o) :
{ }
{
Pair(o) [ "," Members(o) ]
}
private void Pair(JsonObject o) :
{
JsonPrimitive property;
JsonElement value;
}
{
property=JsonMemberName() ":" value=JsonValue()
{
o.add(property.getAsString(), value);
}
}
private JsonPrimitive JsonMemberName() :
{ Token t; JsonPrimitive value; }
{
t=<IDENTIFIER> { return new JsonPrimitive(t.image); } |
value=JsonString() { return value; }
}
private JsonArray JsonArray() :
{ JsonArray array = new JsonArray(); }
{
"[" [ Elements(array) ] "]"
{
array.reverse();
return array;
}
}
private void Elements(JsonArray array) :
{
JsonElement element;
}
{
element=JsonValue() [ "," Elements(array) ]
{ array.add(element); }
}
private JsonElement JsonValue() :
{ JsonElement o = null; }
{
( o=JsonString() |
o=JsonNumber() |
o=JsonObject() |
o=JsonArray() |
o=JsonBoolean() |
o=JsonNull() )
{ return o; }
}
private JsonPrimitive JsonBoolean() :
{ Token t; }
{
t=<BOOLEAN> {
boolean value = Boolean.valueOf(t.image);
return new JsonPrimitive(value);
}
}
private JsonPrimitive JsonPrimitive() :
{
JsonPrimitive value;
}
{
( value=JsonString()) { return value; } |
( value=JsonNumber()) { return value; } |
( value=JsonBoolean()) { return value; }
}
private JsonPrimitive JsonNumber() :
{
JsonPrimitive value;
String intpart = null,
fracpart = null,
exppart = null;
}
{
(value=JsonNaN()) {return value; } |
(intpart=JsonInt() [ fracpart=JsonFrac() ] [ exppart=JsonExp() ])
{
Number n;
if (exppart != null || fracpart != null) {
fracpart = (fracpart == null) ? "" : fracpart;
exppart = (exppart == null) ? "" : exppart;
n = new java.math.BigDecimal(intpart + fracpart + exppart);
} else {
n = new java.math.BigInteger(intpart);
}
return new JsonPrimitive(n);
}
}
private JsonPrimitive JsonNaN() :
{
Token t;
}
{
t=<NAN> {return new JsonPrimitive(Double.NaN); }
}
private String JsonInt() :
{
String digits;
boolean negative = false;
}
{
["-" { negative = true; } ] digits=Digits()
{
if(negative)
return "-" + digits;
return digits;
}
}
private String JsonFrac() :
{ String digits; }
{
"." digits=Digits()
{ return "." + digits; }
}
private String JsonExp() :
{
Token t;
String digits;
}
{
t=<E> digits=Digits()
{ return t.image + digits; }
}
private String Digits() :
{ Token t; }
{
t=<DIGITS>
{ return t.image; }
}
private JsonPrimitive JsonString() :
{ Token t; }
{
(t=<SINGLE_QUOTE_LITERAL> | t=<DOUBLE_QUOTE_LITERAL>) {
String value = StringUnmarshaller.unmarshall(t.image);
return new JsonPrimitive(value);
}
}

View File

@ -118,7 +118,7 @@
</workspaceCodeStylesURL>
</configuration>
</plugin>
<plugin>
<!-- plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>javacc-maven-plugin</artifactId>
<executions>
@ -141,7 +141,7 @@
<version>4.0</version>
</dependency>
</dependencies>
</plugin>
</plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>