#if 0 // (Run through cpp -P -C first) #endif #define PACKAGE org.openjena.atlas.json.io.parserjavacc.javacc #define CLASS JSON_Parser #define PARSERBASE JSON_ParserBase options { JAVA_UNICODE_ESCAPE = true ; UNICODE_INPUT = false ; STATIC = false ; // DEBUG_PARSER = true ; // DEBUG_TOKEN_MANAGER = true ; } PARSER_BEGIN(CLASS) /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package PACKAGE ; public class CLASS extends PARSERBASE { } PARSER_END(CLASS) SKIP : { <" " | "\t" | "\n" | "\r" | "\f"> } TOKEN: { } // Do \ u inside JavaCC?? //TOKEN [IGNORE_CASE] : TOKEN : { | < #QUOTE_3D: "\"\"\""> | < #QUOTE_3S: "'''"> | < STRING_LITERAL1: // Single quoted string "'" ( (~["'","\\","\n","\r"]) | )* "'" > | < STRING_LITERAL2: // Double quoted string "\"" ( (~["\"","\\","\n","\r"]) | )* "\"" > | < STRING_LITERAL_LONG1: ( ("'" | "''")? (~["'","\\"] | ))* > | < STRING_LITERAL_LONG2: ( ("\"" | "\"\"")? (~["\"","\\"] | ))* > | < #DIGITS: (["0"-"9"])+> | < INTEGER: > | < DECIMAL: ( "." ()* | "." ) > | < DOUBLE: // Required exponent. ( (["0"-"9"])+ "." (["0"-"9"])* | "." (["0"-"9"])+ () | (["0"-"9"])+ ) > | < POSITIVE_INTEGER: > | < POSITIVE_DECIMAL: > | < POSITIVE_DOUBLE: > | < NEGATIVE_INTEGER: > | < NEGATIVE_DECIMAL: > | < NEGATIVE_DOUBLE: > | < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ > | | | | < LBRACE: "{" > | < RBRACE: "}" > | < LBRACKET: "[" > | < RBRACKET: "]" > | < LPAREN: "(" > | < RPAREN: ")" > | | | | } // ---- Parser entry points void unit() : { Token t ; } { { startParse(-1, -1) ; } Object() t = { finishParse(t.beginLine, t.beginColumn) ; } } void any() : { Token t ; } { { startParse(-1, -1) ; } (Value())? t = { finishParse(t.beginLine, t.beginColumn) ; } } // ---- Structures void Value() : {} { SimpleValue() | Object() | Array() } void Object() : { Token t ; } { t = { startObject(t.beginLine, t.beginColumn) ; } (Members(t))? t = { finishObject(t.beginLine, t.beginColumn); } } void Members(Token t) : { } { Pair(t) (t = Pair(t))* } void Pair(Token t) : { } { { startPair(t.beginLine, t.beginColumn) ; } String() t = { keyPair(t.beginLine, t.beginColumn) ; } Value() { finishPair(t.beginLine, t.beginColumn) ; } } void Array() : { Token t ; } { t = { startArray(t.beginLine, t.beginColumn) ; } (Elements(t))? t = { finishArray(t.beginLine, t.beginColumn) ; } } void Elements(Token t) : { } { ArrayValue(t.beginLine, t.beginColumn) (t = ArrayValue(t.beginLine, t.beginColumn))* } void ArrayValue(long line, long col) : { } { Value() { element(line, col) ; } } // ---- void SimpleValue() : {} { String() | Number() | True() | False() | Null() } void Number() : { Token t ; } { t = { valueInteger(t.image, t.beginLine, t.beginColumn) ; } | t = { valueDecimal(t.image, t.beginLine, t.beginColumn) ; } | t = { valueDouble(t.image, t.beginLine, t.beginColumn) ; } | t = { valueInteger(t.image, t.beginLine, t.beginColumn) ; } | t = { valueDecimal(t.image, t.beginLine, t.beginColumn) ; } | t = { valueDouble(t.image, t.beginLine, t.beginColumn) ; } | t = { valueInteger(t.image, t.beginLine, t.beginColumn) ; } | t = { valueDecimal(t.image, t.beginLine, t.beginColumn) ; } | t = { valueDouble(t.image, t.beginLine, t.beginColumn) ; } } // Token to Java Object : These rules exist to inject the // necessary Java objects and code for the tokens. void String() : { Token t ; } { t = { valueString(t.image, t.beginLine, t.beginColumn); } // } void True() : { Token t ; } { t = { valueBoolean(true, t.beginLine, t.beginColumn) ; } } void False() : { Token t ; } { t = { valueBoolean(false, t.beginLine, t.beginColumn) ; } } void Null() : { Token t ; } { t = { valueNull(t.beginLine, t.beginColumn) ; } } /* # Local Variables: # tab-width: 4 # indent-tabs-mode: nil # comment-default-style: "//" # End: */