| /** |
| * 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 org.apache.mrql; |
| |
| import java_cup.runtime.*; |
| |
| terminal TRUE, FALSE, NULL, COLON, COMMA, O_BEGIN, O_END, A_BEGIN, A_END; |
| |
| terminal String STRING; |
| terminal Long INTEGER; |
| terminal Double DOUBLE; |
| |
| non terminal MRData top, json, pair, value; |
| non terminal Bag members, elements; |
| |
| precedence left O_BEGIN, O_END, A_BEGIN, A_END; |
| precedence left COMMA; |
| precedence left COLON; |
| |
| start with top; |
| |
| top ::= json:e {: RESULT = e; :} |
| ; |
| json ::= O_BEGIN O_END {: RESULT = new Union((byte)0,new Bag()); :} |
| | O_BEGIN members:m O_END {: RESULT = new Union((byte)0,m); :} |
| | A_BEGIN A_END {: RESULT = new Union((byte)1,new Bag()); :} |
| | A_BEGIN elements:m A_END {: RESULT = new Union((byte)1,m); :} |
| | O_BEGIN O_BEGIN INTEGER:n O_END O_END {: RESULT = new MR_variable((int)n.longValue()); :} |
| ; |
| members ::= pair:p {: RESULT = new Bag(p); :} |
| | members:m COMMA pair:p {: RESULT = m.add_element(p); :} |
| ; |
| pair ::= STRING:s COLON value:v {: RESULT = (new Tuple(2)).set(0,new MR_string(s)).set(1,v); :} |
| ; |
| elements ::= value:v {: RESULT = new Bag(v); :} |
| | elements:es COMMA value:v {: RESULT = es.add_element(v); :} |
| ; |
| value ::= json:e {: RESULT = e; :} |
| | STRING:s {: RESULT = new Union((byte)2,new MR_string(s)); :} |
| | INTEGER:n {: RESULT = new Union((byte)3,new MR_long(n.longValue())); :} |
| | DOUBLE:n {: RESULT = new Union((byte)4,new MR_double(n.doubleValue())); :} |
| | TRUE {: RESULT = new Union((byte)5,new MR_bool(true)); :} |
| | FALSE {: RESULT = new Union((byte)5,new MR_bool(false)); :} |
| | NULL {: RESULT = new Union((byte)6,new Tuple(0)); :} |
| ; |