// ===========================================================================
// This file has been generated by
// Rats! Parser Generator, version 2.3.1,
// (C) 2004-2012 Robert Grimm,
// on Wednesday, July 22, 2015 at 6:52:28 PM.
// Edit at your own risk.
// ===========================================================================
package xtc.lang.cpp;
import java.io.Reader;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import xtc.util.Action;
import xtc.util.Pair;
import xtc.tree.Node;
import xtc.tree.GNode;
import xtc.tree.Printer;
import xtc.parser.ParserBase;
import xtc.parser.Column;
import xtc.parser.Result;
import xtc.parser.SemanticValue;
import xtc.parser.ParseError;
/**
* Packrat parser for grammar <code>xtc.lang.cpp.Condition</code>.
*
* <p />This class has been generated by the <i>Rats!</i> parser
* generator, version 2.3.1, (C) 2004-2012 Robert Grimm.
*/
public final class ExpressionRats extends ParserBase {
/** The CPP_KEYWORDS set. */
public static final Set<String> CPP_KEYWORDS = new HashSet<String>();
/** The C99 flag. */
public static final boolean C99 = true;
/** The GCC flag. */
public static final boolean GCC = true;
// =========================================================================
/** Memoization table column. */
static final class ExpressionRatsColumn extends Column {
Result fCondition$CharacterLiteral;
Result fConstantExpression;
Result fConditionalExpression;
Result fLogicalOrExpression;
Result fUnaryExpression;
Result fSymbol;
}
// =========================================================================
/**
* Create a new packrat parser.
*
* @param reader The reader.
* @param file The file name.
*/
public ExpressionRats(final Reader reader, final String file) {
super(reader, file);
}
/**
* Create a new packrat parser.
*
* @param reader The file reader.
* @param file The file name.
* @param size The file size.
*/
public ExpressionRats(final Reader reader, final String file, final int size) {
super(reader, file, size);
}
// =========================================================================
protected Column newColumn() {
return new ExpressionRatsColumn();
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.Constant.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pCondition$Constant(final int yyStart) throws IOException {
Result yyResult;
Node yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyResult = pCondition$IntegerConstant(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyValue = yyResult.semanticValue();
yyResult = pSpacing(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
return yyResult.createValue(yyValue, yyError);
}
}
// Alternative 2.
yyResult = pCondition$CharacterConstant(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyValue = yyResult.semanticValue();
yyResult = pSpacing(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
return yyResult.createValue(yyValue, yyError);
}
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.IntegerConstant.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pCondition$IntegerConstant(final int yyStart)
throws IOException {
Result yyResult;
Node yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Hex>.
yyResult = pCondition$HexConstant(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final String v$g$1 = yyResult.semanticValue();
yyValue = GNode.create("IntegerConstant", v$g$1);
yyValue.setLocation(location(yyStart));
return yyResult.createValue(yyValue, yyError);
}
// Alternative <Octal>.
yyResult = pCondition$OctalConstant(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final String v$g$2 = yyResult.semanticValue();
yyValue = GNode.create("IntegerConstant", v$g$2);
yyValue.setLocation(location(yyStart));
return yyResult.createValue(yyValue, yyError);
}
// Alternative <Decimal>.
yyResult = pCondition$DecimalConstant(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final String v$g$3 = yyResult.semanticValue();
yyValue = GNode.create("IntegerConstant", v$g$3);
yyValue.setLocation(location(yyStart));
return yyResult.createValue(yyValue, yyError);
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.DecimalConstant.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pCondition$DecimalConstant(final int yyStart)
throws IOException {
int yyC;
int yyIndex;
Result yyResult;
int yyRepetition1;
int yyOption1;
String yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyC = character(yyStart);
if (-1 != yyC) {
yyIndex = yyStart + 1;
switch (yyC) {
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
{
yyRepetition1 = yyIndex;
while (true) {
yyC = character(yyRepetition1);
if (-1 != yyC) {
yyIndex = yyRepetition1 + 1;
switch (yyC) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
{
yyRepetition1 = yyIndex;
continue;
}
default:
/* No match. */
}
}
break;
}
yyOption1 = yyRepetition1;
yyResult = pCondition$IntegerSuffix(yyOption1);
yyError = yyResult.select(yyError, yyOption1);
if (yyResult.hasValue()) {
yyOption1 = yyResult.index;
}
yyValue = difference(yyStart, yyOption1);
return new SemanticValue(yyValue, yyOption1, yyError);
}
default:
/* No match. */
}
}
// Done.
yyError = yyError.select("decimal constant expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.HexConstant.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pCondition$HexConstant(final int yyStart)
throws IOException {
int yyC;
int yyIndex;
Result yyResult;
int yyRepetition1;
boolean yyRepeated1;
int yyOption1;
String yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyResult = pCondition$HexPrefix(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyRepetition1 = yyResult.index;
yyRepeated1 = false;
while (true) {
yyC = character(yyRepetition1);
if (-1 != yyC) {
yyIndex = yyRepetition1 + 1;
switch (yyC) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
{
yyRepetition1 = yyIndex;
yyRepeated1 = true;
continue;
}
default:
/* No match. */
}
}
break;
}
if (yyRepeated1) {
yyOption1 = yyRepetition1;
yyResult = pCondition$IntegerSuffix(yyOption1);
yyError = yyResult.select(yyError, yyOption1);
if (yyResult.hasValue()) {
yyOption1 = yyResult.index;
}
yyValue = difference(yyStart, yyOption1);
return new SemanticValue(yyValue, yyOption1, yyError);
}
}
// Done.
yyError = yyError.select("hex constant expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.HexPrefix.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pCondition$HexPrefix(final int yyStart) throws IOException {
int yyC;
int yyIndex;
Void yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyC = character(yyStart);
if ('0' == yyC) {
yyIndex = yyStart + 1;
yyC = character(yyIndex);
if (-1 != yyC) {
yyIndex = yyIndex + 1;
switch (yyC) {
case 'X':
case 'x':
{
yyValue = null;
return new SemanticValue(yyValue, yyIndex, yyError);
}
default:
/* No match. */
}
}
}
// Done.
yyError = yyError.select("hex prefix expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.OctalConstant.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pCondition$OctalConstant(final int yyStart)
throws IOException {
int yyC;
int yyIndex;
Result yyResult;
int yyRepetition1;
int yyOption1;
String yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyC = character(yyStart);
if ('0' == yyC) {
yyIndex = yyStart + 1;
yyRepetition1 = yyIndex;
while (true) {
yyC = character(yyRepetition1);
if (-1 != yyC) {
yyIndex = yyRepetition1 + 1;
switch (yyC) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
{
yyRepetition1 = yyIndex;
continue;
}
default:
/* No match. */
}
}
break;
}
yyOption1 = yyRepetition1;
yyResult = pCondition$IntegerSuffix(yyOption1);
yyError = yyResult.select(yyError, yyOption1);
if (yyResult.hasValue()) {
yyOption1 = yyResult.index;
}
yyValue = difference(yyStart, yyOption1);
return new SemanticValue(yyValue, yyOption1, yyError);
}
// Done.
yyError = yyError.select("octal constant expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.IntegerSuffix.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pCondition$IntegerSuffix(final int yyStart)
throws IOException {
int yyC;
int yyIndex;
Result yyResult;
Void yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyResult = pCondition$LongLongSuffix(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final int yyChoice1 = yyResult.index;
// Nested alternative 1.
yyC = character(yyChoice1);
if (-1 != yyC) {
yyIndex = yyChoice1 + 1;
switch (yyC) {
case 'U':
case 'u':
{
yyValue = null;
return new SemanticValue(yyValue, yyIndex, yyError);
}
default:
/* No match. */
}
}
// Nested alternative 2.
yyValue = null;
return new SemanticValue(yyValue, yyChoice1, yyError);
}
// Alternative 2.
yyC = character(yyStart);
if (-1 != yyC) {
yyIndex = yyStart + 1;
switch (yyC) {
case 'L':
case 'l':
{
final int yyChoice1 = yyIndex;
// Nested alternative 1.
yyC = character(yyChoice1);
if (-1 != yyC) {
yyIndex = yyChoice1 + 1;
switch (yyC) {
case 'U':
case 'u':
{
yyValue = null;
return new SemanticValue(yyValue, yyIndex, yyError);
}
default:
/* No match. */
}
}
// Nested alternative 2.
yyValue = null;
return new SemanticValue(yyValue, yyChoice1, yyError);
}
case 'U':
case 'u':
{
final int yyChoice1 = yyIndex;
// Nested alternative 1.
yyC = character(yyChoice1);
if (-1 != yyC) {
yyIndex = yyChoice1 + 1;
switch (yyC) {
case 'l':
{
yyC = character(yyIndex);
if (-1 != yyC) {
yyIndex = yyIndex + 1;
if ('l' == yyC) {
yyValue = null;
return new SemanticValue(yyValue, yyIndex, yyError);
}
}
}
break;
case 'L':
{
yyC = character(yyIndex);
if (-1 != yyC) {
yyIndex = yyIndex + 1;
if ('L' == yyC) {
yyValue = null;
return new SemanticValue(yyValue, yyIndex, yyError);
}
}
}
break;
default:
/* No match. */
}
}
// Nested alternative 2.
yyC = character(yyChoice1);
if (-1 != yyC) {
yyIndex = yyChoice1 + 1;
switch (yyC) {
case 'L':
case 'l':
{
yyValue = null;
return new SemanticValue(yyValue, yyIndex, yyError);
}
default:
/* No match. */
}
}
// Nested alternative 3.
yyValue = null;
return new SemanticValue(yyValue, yyChoice1, yyError);
}
default:
/* No match. */
}
}
// Done.
yyError = yyError.select("integer suffix expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.LongLongSuffix.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pCondition$LongLongSuffix(final int yyStart)
throws IOException {
int yyC;
int yyIndex;
Void yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyC = character(yyStart);
if (-1 != yyC) {
yyIndex = yyStart + 1;
switch (yyC) {
case 'l':
{
yyC = character(yyIndex);
if (-1 != yyC) {
yyIndex = yyIndex + 1;
if ('l' == yyC) {
yyValue = null;
return new SemanticValue(yyValue, yyIndex, yyError);
}
}
}
break;
case 'L':
{
yyC = character(yyIndex);
if (-1 != yyC) {
yyIndex = yyIndex + 1;
if ('L' == yyC) {
yyValue = null;
return new SemanticValue(yyValue, yyIndex, yyError);
}
}
}
break;
default:
/* No match. */
}
}
// Done.
yyError = yyError.select("long long suffix expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.CharacterConstant.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pCondition$CharacterConstant(final int yyStart)
throws IOException {
Result yyResult;
Node yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyResult = pCondition$WideCharacterLiteral(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final String v$g$1 = yyResult.semanticValue();
yyValue = GNode.create("CharacterConstant", v$g$1);
yyValue.setLocation(location(yyStart));
return yyResult.createValue(yyValue, yyError);
}
// Alternative 2.
yyResult = pCondition$CharacterLiteral(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final String v$g$2 = yyResult.semanticValue();
yyValue = GNode.create("CharacterConstant", v$g$2);
yyValue.setLocation(location(yyStart));
return yyResult.createValue(yyValue, yyError);
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.WideCharacterLiteral.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pCondition$WideCharacterLiteral(final int yyStart)
throws IOException {
int yyC;
int yyIndex;
Result yyResult;
String yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyC = character(yyStart);
if ('L' == yyC) {
yyIndex = yyStart + 1;
yyResult = pCondition$CharacterLiteral(yyIndex);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyValue = difference(yyStart, yyResult.index);
return yyResult.createValue(yyValue, yyError);
}
}
// Done.
yyError = yyError.select("wide character literal expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.CharacterLiteral.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pCondition$CharacterLiteral(final int yyStart)
throws IOException {
ExpressionRatsColumn yyColumn = (ExpressionRatsColumn)column(yyStart);
if (null == yyColumn.fCondition$CharacterLiteral)
yyColumn.fCondition$CharacterLiteral = pCondition$CharacterLiteral$1(yyStart);
return yyColumn.fCondition$CharacterLiteral;
}
/** Actually parse xtc.lang.cpp.Condition.CharacterLiteral. */
private Result pCondition$CharacterLiteral$1(final int yyStart)
throws IOException {
int yyC;
int yyIndex;
Result yyResult;
String yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyC = character(yyStart);
if ('\'' == yyC) {
yyIndex = yyStart + 1;
yyResult = pCondition$CharacterContents(yyIndex);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyC = character(yyResult.index);
if ('\'' == yyC) {
yyIndex = yyResult.index + 1;
yyValue = difference(yyStart, yyIndex);
return new SemanticValue(yyValue, yyIndex, yyError);
}
}
}
// Done.
yyError = yyError.select("character literal expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.CharacterContents.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pCondition$CharacterContents(final int yyStart)
throws IOException {
int yyC;
int yyIndex;
Result yyResult;
int yyRepetition1;
boolean yyRepeated1;
Void yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyRepetition1 = yyStart;
yyRepeated1 = false;
while (true) {
final int yyChoice1 = yyRepetition1;
// Nested alternative 1.
yyC = character(yyChoice1);
if (-1 != yyC) {
yyIndex = yyChoice1 + 1;
switch (yyC) {
case '\\':
{
final int yyChoice2 = yyIndex;
// Nested alternative 1.
yyResult = pCondition$EscapeCode(yyChoice2);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyRepetition1 = yyResult.index;
yyRepeated1 = true;
continue;
}
// Nested alternative 2.
yyC = character(yyChoice2);
if (-1 != yyC) {
yyIndex = yyChoice2 + 1;
switch (yyC) {
case 'u':
{
yyResult = pCondition$HexQuad(yyIndex);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyRepetition1 = yyResult.index;
yyRepeated1 = true;
continue;
}
}
break;
case 'U':
{
yyResult = pCondition$HexQuad(yyIndex);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyResult = pCondition$HexQuad(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyRepetition1 = yyResult.index;
yyRepeated1 = true;
continue;
}
}
}
break;
default:
/* No match. */
}
}
}
break;
default:
/* No match. */
}
}
// Nested alternative 2.
yyC = character(yyChoice1);
if (-1 != yyC) {
yyIndex = yyChoice1 + 1;
switch (yyC) {
case '\n':
case '\r':
case '\'':
case '\\':
/* No match. */
break;
default:
{
yyRepetition1 = yyIndex;
yyRepeated1 = true;
continue;
}
}
}
break;
}
if (yyRepeated1) {
yyValue = null;
return new SemanticValue(yyValue, yyRepetition1, yyError);
}
// Done.
yyError = yyError.select("character contents expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.EscapeCode.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pCondition$EscapeCode(final int yyStart) throws IOException {
int yyC;
int yyIndex;
int yyRepetition1;
boolean yyRepeated1;
Void yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyC = character(yyStart);
if (-1 != yyC) {
yyIndex = yyStart + 1;
switch (yyC) {
case '\"':
case '\'':
case '?':
case '\\':
case 'a':
case 'b':
case 'f':
case 'n':
case 'r':
case 't':
case 'v':
{
yyValue = null;
return new SemanticValue(yyValue, yyIndex, yyError);
}
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
{
final int yyChoice1 = yyIndex;
// Nested alternative 1.
yyC = character(yyChoice1);
if (-1 != yyC) {
yyIndex = yyChoice1 + 1;
switch (yyC) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
{
final int yyChoice2 = yyIndex;
// Nested alternative 1.
yyC = character(yyChoice2);
if (-1 != yyC) {
yyIndex = yyChoice2 + 1;
switch (yyC) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
{
yyValue = null;
return new SemanticValue(yyValue, yyIndex, yyError);
}
default:
/* No match. */
}
}
// Nested alternative 2.
yyValue = null;
return new SemanticValue(yyValue, yyChoice2, yyError);
}
default:
/* No match. */
}
}
// Nested alternative 2.
yyValue = null;
return new SemanticValue(yyValue, yyChoice1, yyError);
}
case 'x':
{
yyRepetition1 = yyIndex;
yyRepeated1 = false;
while (true) {
yyC = character(yyRepetition1);
if (-1 != yyC) {
yyIndex = yyRepetition1 + 1;
switch (yyC) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
{
yyRepetition1 = yyIndex;
yyRepeated1 = true;
continue;
}
default:
/* No match. */
}
}
break;
}
if (yyRepeated1) {
yyValue = null;
return new SemanticValue(yyValue, yyRepetition1, yyError);
}
}
break;
default:
/* No match. */
}
}
// Done.
yyError = yyError.select("escape code expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.HexQuad.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pCondition$HexQuad(final int yyStart) throws IOException {
int yyC;
int yyIndex;
Void yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyC = character(yyStart);
if (-1 != yyC) {
yyIndex = yyStart + 1;
switch (yyC) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
{
yyC = character(yyIndex);
if (-1 != yyC) {
yyIndex = yyIndex + 1;
switch (yyC) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
{
yyC = character(yyIndex);
if (-1 != yyC) {
yyIndex = yyIndex + 1;
switch (yyC) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
{
yyC = character(yyIndex);
if (-1 != yyC) {
yyIndex = yyIndex + 1;
switch (yyC) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
{
yyValue = null;
return new SemanticValue(yyValue, yyIndex, yyError);
}
default:
/* No match. */
}
}
}
break;
default:
/* No match. */
}
}
}
break;
default:
/* No match. */
}
}
}
break;
default:
/* No match. */
}
}
// Done.
yyError = yyError.select("hex quad expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.ConstantExpression.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
public Result pConstantExpression(final int yyStart) throws IOException {
ExpressionRatsColumn yyColumn = (ExpressionRatsColumn)column(yyStart);
if (null == yyColumn.fConstantExpression)
yyColumn.fConstantExpression = pConstantExpression$1(yyStart);
return yyColumn.fConstantExpression;
}
/** Actually parse xtc.lang.cpp.Condition.ConstantExpression. */
private Result pConstantExpression$1(final int yyStart) throws IOException {
Result yyResult;
Node yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyResult = pConditionalExpression(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyValue = yyResult.semanticValue();
return yyResult.createValue(yyValue, yyError);
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.ConditionalExpression.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pConditionalExpression(final int yyStart)
throws IOException {
ExpressionRatsColumn yyColumn = (ExpressionRatsColumn)column(yyStart);
if (null == yyColumn.fConditionalExpression)
yyColumn.fConditionalExpression = pConditionalExpression$1(yyStart);
return yyColumn.fConditionalExpression;
}
/** Actually parse xtc.lang.cpp.Condition.ConditionalExpression. */
private Result pConditionalExpression$1(final int yyStart)
throws IOException {
Result yyResult;
int yyBase;
Node yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Conditional>.
yyResult = pLogicalOrExpression(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final Node v$g$1 = yyResult.semanticValue();
yyBase = yyResult.index;
yyResult = pSymbol(yyBase);
if (yyResult.hasValue("?")) {
yyResult = pConstantExpression(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final Node v$g$2 = yyResult.semanticValue();
yyBase = yyResult.index;
yyResult = pSymbol(yyBase);
if (yyResult.hasValue(":")) {
yyResult = pConditionalExpression(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final Node v$g$3 = yyResult.semanticValue();
yyValue = GNode.create("ConditionalExpression", v$g$1, v$g$2, v$g$3);
yyValue.setLocation(location(yyStart));
return yyResult.createValue(yyValue, yyError);
}
} else {
yyError = yyError.select("':' expected", yyBase);
}
}
} else {
yyError = yyError.select("'?' expected", yyBase);
}
}
// Alternative <Base>.
yyResult = pLogicalOrExpression(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyValue = yyResult.semanticValue();
return yyResult.createValue(yyValue, yyError);
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.LogicalOrExpression.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pLogicalOrExpression(final int yyStart) throws IOException {
ExpressionRatsColumn yyColumn = (ExpressionRatsColumn)column(yyStart);
if (null == yyColumn.fLogicalOrExpression)
yyColumn.fLogicalOrExpression = pLogicalOrExpression$1(yyStart);
return yyColumn.fLogicalOrExpression;
}
/** Actually parse xtc.lang.cpp.Condition.LogicalOrExpression. */
private Result pLogicalOrExpression$1(final int yyStart)
throws IOException {
Result yyResult;
int yyRepetition1;
Pair<Action<Node>> yyRepValue1;
Node yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Base>.
yyResult = pLogicalAndExpression(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyValue = yyResult.semanticValue();
yyRepetition1 = yyResult.index;
yyRepValue1 = Pair.empty();
while (true) {
yyResult = pLogicalOrExpression$$Tail1(yyRepetition1);
yyError = yyResult.select(yyError, yyRepetition1);
if (yyResult.hasValue()) {
final Action<Node> v$3 = yyResult.semanticValue();
yyRepetition1 = yyResult.index;
yyRepValue1 = new Pair<Action<Node>>(v$3, yyRepValue1);
continue;
}
break;
}
{ // Start scope for v$4.
final Pair<Action<Node>> v$4 = yyRepValue1.reverse();
yyValue = apply(v$4, yyValue, yyStart);
return new SemanticValue(yyValue, yyRepetition1, yyError);
} // End scope for v$4.
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse synthetic nonterminal
* xtc.lang.cpp.Condition.LogicalOrExpression$$Tail1.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pLogicalOrExpression$$Tail1(final int yyStart)
throws IOException {
Result yyResult;
Action<Node> yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Or>.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue("||")) {
yyResult = pLogicalAndExpression(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final Node v$g$2 = yyResult.semanticValue();
yyValue = new Action<Node>() {
public Node run(Node v$1) {
return GNode.create("LogicalOrExpression", v$1, v$g$2);
}};
return yyResult.createValue(yyValue, yyError);
}
}
// Done.
yyError = yyError.select("logical or expression expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.LogicalAndExpression.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pLogicalAndExpression(final int yyStart) throws IOException {
Result yyResult;
int yyRepetition1;
Pair<Action<Node>> yyRepValue1;
Node yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Base>.
yyResult = pBitwiseOrExpression(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyValue = yyResult.semanticValue();
yyRepetition1 = yyResult.index;
yyRepValue1 = Pair.empty();
while (true) {
yyResult = pLogicalAndExpression$$Tail1(yyRepetition1);
yyError = yyResult.select(yyError, yyRepetition1);
if (yyResult.hasValue()) {
final Action<Node> v$3 = yyResult.semanticValue();
yyRepetition1 = yyResult.index;
yyRepValue1 = new Pair<Action<Node>>(v$3, yyRepValue1);
continue;
}
break;
}
{ // Start scope for v$4.
final Pair<Action<Node>> v$4 = yyRepValue1.reverse();
yyValue = apply(v$4, yyValue, yyStart);
return new SemanticValue(yyValue, yyRepetition1, yyError);
} // End scope for v$4.
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse synthetic nonterminal
* xtc.lang.cpp.Condition.LogicalAndExpression$$Tail1.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pLogicalAndExpression$$Tail1(final int yyStart)
throws IOException {
Result yyResult;
Action<Node> yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <And>.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue("&&")) {
yyResult = pBitwiseOrExpression(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final Node v$g$2 = yyResult.semanticValue();
yyValue = new Action<Node>() {
public Node run(Node v$1) {
return GNode.create("LogicalAndExpression", v$1, v$g$2);
}};
return yyResult.createValue(yyValue, yyError);
}
}
// Done.
yyError = yyError.select("logical and expression expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.BitwiseOrExpression.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pBitwiseOrExpression(final int yyStart) throws IOException {
Result yyResult;
int yyRepetition1;
Pair<Action<Node>> yyRepValue1;
Node yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Base>.
yyResult = pBitwiseXorExpression(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyValue = yyResult.semanticValue();
yyRepetition1 = yyResult.index;
yyRepValue1 = Pair.empty();
while (true) {
yyResult = pBitwiseOrExpression$$Tail1(yyRepetition1);
yyError = yyResult.select(yyError, yyRepetition1);
if (yyResult.hasValue()) {
final Action<Node> v$3 = yyResult.semanticValue();
yyRepetition1 = yyResult.index;
yyRepValue1 = new Pair<Action<Node>>(v$3, yyRepValue1);
continue;
}
break;
}
{ // Start scope for v$4.
final Pair<Action<Node>> v$4 = yyRepValue1.reverse();
yyValue = apply(v$4, yyValue, yyStart);
return new SemanticValue(yyValue, yyRepetition1, yyError);
} // End scope for v$4.
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse synthetic nonterminal
* xtc.lang.cpp.Condition.BitwiseOrExpression$$Tail1.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pBitwiseOrExpression$$Tail1(final int yyStart)
throws IOException {
Result yyResult;
Action<Node> yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Or>.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue("|")) {
yyResult = pBitwiseXorExpression(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final Node v$g$2 = yyResult.semanticValue();
yyValue = new Action<Node>() {
public Node run(Node v$1) {
return GNode.create("BitwiseOrExpression", v$1, v$g$2);
}};
return yyResult.createValue(yyValue, yyError);
}
}
// Done.
yyError = yyError.select("bitwise or expression expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.BitwiseXorExpression.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pBitwiseXorExpression(final int yyStart) throws IOException {
Result yyResult;
int yyRepetition1;
Pair<Action<Node>> yyRepValue1;
Node yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Base>.
yyResult = pBitwiseAndExpression(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyValue = yyResult.semanticValue();
yyRepetition1 = yyResult.index;
yyRepValue1 = Pair.empty();
while (true) {
yyResult = pBitwiseXorExpression$$Tail1(yyRepetition1);
yyError = yyResult.select(yyError, yyRepetition1);
if (yyResult.hasValue()) {
final Action<Node> v$3 = yyResult.semanticValue();
yyRepetition1 = yyResult.index;
yyRepValue1 = new Pair<Action<Node>>(v$3, yyRepValue1);
continue;
}
break;
}
{ // Start scope for v$4.
final Pair<Action<Node>> v$4 = yyRepValue1.reverse();
yyValue = apply(v$4, yyValue, yyStart);
return new SemanticValue(yyValue, yyRepetition1, yyError);
} // End scope for v$4.
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse synthetic nonterminal
* xtc.lang.cpp.Condition.BitwiseXorExpression$$Tail1.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pBitwiseXorExpression$$Tail1(final int yyStart)
throws IOException {
Result yyResult;
Action<Node> yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Xor>.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue("^")) {
yyResult = pBitwiseAndExpression(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final Node v$g$2 = yyResult.semanticValue();
yyValue = new Action<Node>() {
public Node run(Node v$1) {
return GNode.create("BitwiseXorExpression", v$1, v$g$2);
}};
return yyResult.createValue(yyValue, yyError);
}
}
// Done.
yyError = yyError.select("bitwise xor expression expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.BitwiseAndExpression.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pBitwiseAndExpression(final int yyStart) throws IOException {
Result yyResult;
int yyRepetition1;
Pair<Action<Node>> yyRepValue1;
Node yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Base>.
yyResult = pEqualityExpression(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyValue = yyResult.semanticValue();
yyRepetition1 = yyResult.index;
yyRepValue1 = Pair.empty();
while (true) {
yyResult = pBitwiseAndExpression$$Tail1(yyRepetition1);
yyError = yyResult.select(yyError, yyRepetition1);
if (yyResult.hasValue()) {
final Action<Node> v$3 = yyResult.semanticValue();
yyRepetition1 = yyResult.index;
yyRepValue1 = new Pair<Action<Node>>(v$3, yyRepValue1);
continue;
}
break;
}
{ // Start scope for v$4.
final Pair<Action<Node>> v$4 = yyRepValue1.reverse();
yyValue = apply(v$4, yyValue, yyStart);
return new SemanticValue(yyValue, yyRepetition1, yyError);
} // End scope for v$4.
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse synthetic nonterminal
* xtc.lang.cpp.Condition.BitwiseAndExpression$$Tail1.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pBitwiseAndExpression$$Tail1(final int yyStart)
throws IOException {
Result yyResult;
Action<Node> yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <And>.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue("&")) {
yyResult = pEqualityExpression(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final Node v$g$2 = yyResult.semanticValue();
yyValue = new Action<Node>() {
public Node run(Node v$1) {
return GNode.create("BitwiseAndExpression", v$1, v$g$2);
}};
return yyResult.createValue(yyValue, yyError);
}
}
// Done.
yyError = yyError.select("bitwise and expression expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.EqualityExpression.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pEqualityExpression(final int yyStart) throws IOException {
Result yyResult;
int yyRepetition1;
Pair<Action<Node>> yyRepValue1;
Node yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Base>.
yyResult = pRelationalExpression(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyValue = yyResult.semanticValue();
yyRepetition1 = yyResult.index;
yyRepValue1 = Pair.empty();
while (true) {
yyResult = pEqualityExpression$$Tail1(yyRepetition1);
yyError = yyResult.select(yyError, yyRepetition1);
if (yyResult.hasValue()) {
final Action<Node> v$4 = yyResult.semanticValue();
yyRepetition1 = yyResult.index;
yyRepValue1 = new Pair<Action<Node>>(v$4, yyRepValue1);
continue;
}
break;
}
{ // Start scope for v$5.
final Pair<Action<Node>> v$5 = yyRepValue1.reverse();
yyValue = apply(v$5, yyValue, yyStart);
return new SemanticValue(yyValue, yyRepetition1, yyError);
} // End scope for v$5.
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse synthetic nonterminal
* xtc.lang.cpp.Condition.EqualityExpression$$Tail1.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pEqualityExpression$$Tail1(final int yyStart)
throws IOException {
Result yyResult;
Action<Node> yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Recursion>.
yyResult = pEqualityOperator(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final String v$g$2 = yyResult.semanticValue();
yyResult = pRelationalExpression(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final Node v$g$3 = yyResult.semanticValue();
yyValue = new Action<Node>() {
public Node run(Node v$1) {
return GNode.create("EqualityExpression", v$1, v$g$2, v$g$3);
}};
return yyResult.createValue(yyValue, yyError);
}
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.EqualityOperator.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pEqualityOperator(final int yyStart) throws IOException {
Result yyResult;
String yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Equal>.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue("==")) {
yyValue = "==";
return yyResult.createValue(yyValue, yyError);
}
// Alternative <NotEqual>.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue("!=")) {
yyValue = "!=";
return yyResult.createValue(yyValue, yyError);
}
// Done.
yyError = yyError.select("equality operator expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.RelationalExpression.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pRelationalExpression(final int yyStart) throws IOException {
Result yyResult;
int yyRepetition1;
Pair<Action<Node>> yyRepValue1;
Node yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Base>.
yyResult = pShiftExpression(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyValue = yyResult.semanticValue();
yyRepetition1 = yyResult.index;
yyRepValue1 = Pair.empty();
while (true) {
yyResult = pRelationalExpression$$Tail1(yyRepetition1);
yyError = yyResult.select(yyError, yyRepetition1);
if (yyResult.hasValue()) {
final Action<Node> v$4 = yyResult.semanticValue();
yyRepetition1 = yyResult.index;
yyRepValue1 = new Pair<Action<Node>>(v$4, yyRepValue1);
continue;
}
break;
}
{ // Start scope for v$5.
final Pair<Action<Node>> v$5 = yyRepValue1.reverse();
yyValue = apply(v$5, yyValue, yyStart);
return new SemanticValue(yyValue, yyRepetition1, yyError);
} // End scope for v$5.
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse synthetic nonterminal
* xtc.lang.cpp.Condition.RelationalExpression$$Tail1.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pRelationalExpression$$Tail1(final int yyStart)
throws IOException {
Result yyResult;
Action<Node> yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Recursion>.
yyResult = pRelationalOperator(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final String v$g$2 = yyResult.semanticValue();
yyResult = pShiftExpression(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final Node v$g$3 = yyResult.semanticValue();
yyValue = new Action<Node>() {
public Node run(Node v$1) {
return GNode.create("RelationalExpression", v$1, v$g$2, v$g$3);
}};
return yyResult.createValue(yyValue, yyError);
}
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.RelationalOperator.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pRelationalOperator(final int yyStart) throws IOException {
Result yyResult;
String yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <LessEqual>.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue("<=")) {
yyValue = "<=";
return yyResult.createValue(yyValue, yyError);
}
// Alternative <Less>.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue("<")) {
yyValue = "<";
return yyResult.createValue(yyValue, yyError);
}
// Alternative <GreaterEqual>.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue(">=")) {
yyValue = ">=";
return yyResult.createValue(yyValue, yyError);
}
// Alternative <Greater>.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue(">")) {
yyValue = ">";
return yyResult.createValue(yyValue, yyError);
}
// Done.
yyError = yyError.select("relational operator expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.ShiftExpression.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pShiftExpression(final int yyStart) throws IOException {
Result yyResult;
int yyRepetition1;
Pair<Action<Node>> yyRepValue1;
Node yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Base>.
yyResult = pAdditiveExpression(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyValue = yyResult.semanticValue();
yyRepetition1 = yyResult.index;
yyRepValue1 = Pair.empty();
while (true) {
yyResult = pShiftExpression$$Tail1(yyRepetition1);
yyError = yyResult.select(yyError, yyRepetition1);
if (yyResult.hasValue()) {
final Action<Node> v$4 = yyResult.semanticValue();
yyRepetition1 = yyResult.index;
yyRepValue1 = new Pair<Action<Node>>(v$4, yyRepValue1);
continue;
}
break;
}
{ // Start scope for v$5.
final Pair<Action<Node>> v$5 = yyRepValue1.reverse();
yyValue = apply(v$5, yyValue, yyStart);
return new SemanticValue(yyValue, yyRepetition1, yyError);
} // End scope for v$5.
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse synthetic nonterminal
* xtc.lang.cpp.Condition.ShiftExpression$$Tail1.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pShiftExpression$$Tail1(final int yyStart)
throws IOException {
Result yyResult;
Action<Node> yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Recursion>.
yyResult = pShiftOperator(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final String v$g$2 = yyResult.semanticValue();
yyResult = pAdditiveExpression(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final Node v$g$3 = yyResult.semanticValue();
yyValue = new Action<Node>() {
public Node run(Node v$1) {
return GNode.create("ShiftExpression", v$1, v$g$2, v$g$3);
}};
return yyResult.createValue(yyValue, yyError);
}
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.ShiftOperator.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pShiftOperator(final int yyStart) throws IOException {
Result yyResult;
String yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Left>.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue("<<")) {
yyValue = "<<";
return yyResult.createValue(yyValue, yyError);
}
// Alternative <Right>.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue(">>")) {
yyValue = ">>";
return yyResult.createValue(yyValue, yyError);
}
// Done.
yyError = yyError.select("shift operator expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.AdditiveExpression.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pAdditiveExpression(final int yyStart) throws IOException {
Result yyResult;
int yyRepetition1;
Pair<Action<Node>> yyRepValue1;
Node yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Base>.
yyResult = pMultiplicativeExpression(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyValue = yyResult.semanticValue();
yyRepetition1 = yyResult.index;
yyRepValue1 = Pair.empty();
while (true) {
yyResult = pAdditiveExpression$$Tail1(yyRepetition1);
yyError = yyResult.select(yyError, yyRepetition1);
if (yyResult.hasValue()) {
final Action<Node> v$4 = yyResult.semanticValue();
yyRepetition1 = yyResult.index;
yyRepValue1 = new Pair<Action<Node>>(v$4, yyRepValue1);
continue;
}
break;
}
{ // Start scope for v$5.
final Pair<Action<Node>> v$5 = yyRepValue1.reverse();
yyValue = apply(v$5, yyValue, yyStart);
return new SemanticValue(yyValue, yyRepetition1, yyError);
} // End scope for v$5.
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse synthetic nonterminal
* xtc.lang.cpp.Condition.AdditiveExpression$$Tail1.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pAdditiveExpression$$Tail1(final int yyStart)
throws IOException {
Result yyResult;
Action<Node> yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Recursion>.
yyResult = pAdditiveOperator(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final String v$g$2 = yyResult.semanticValue();
yyResult = pMultiplicativeExpression(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final Node v$g$3 = yyResult.semanticValue();
yyValue = new Action<Node>() {
public Node run(Node v$1) {
return GNode.create("AdditiveExpression", v$1, v$g$2, v$g$3);
}};
return yyResult.createValue(yyValue, yyError);
}
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.AdditiveOperator.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pAdditiveOperator(final int yyStart) throws IOException {
Result yyResult;
String yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Plus>.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue("+")) {
yyValue = "+";
return yyResult.createValue(yyValue, yyError);
}
// Alternative <Minus>.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue("-")) {
yyValue = "-";
return yyResult.createValue(yyValue, yyError);
}
// Done.
yyError = yyError.select("additive operator expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.MultiplicativeExpression.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pMultiplicativeExpression(final int yyStart)
throws IOException {
Result yyResult;
int yyRepetition1;
Pair<Action<Node>> yyRepValue1;
Node yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Base>.
yyResult = pUnaryExpression(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyValue = yyResult.semanticValue();
yyRepetition1 = yyResult.index;
yyRepValue1 = Pair.empty();
while (true) {
yyResult = pMultiplicativeExpression$$Tail1(yyRepetition1);
yyError = yyResult.select(yyError, yyRepetition1);
if (yyResult.hasValue()) {
final Action<Node> v$4 = yyResult.semanticValue();
yyRepetition1 = yyResult.index;
yyRepValue1 = new Pair<Action<Node>>(v$4, yyRepValue1);
continue;
}
break;
}
{ // Start scope for v$5.
final Pair<Action<Node>> v$5 = yyRepValue1.reverse();
yyValue = apply(v$5, yyValue, yyStart);
return new SemanticValue(yyValue, yyRepetition1, yyError);
} // End scope for v$5.
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse synthetic nonterminal
* xtc.lang.cpp.Condition.MultiplicativeExpression$$Tail1.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pMultiplicativeExpression$$Tail1(final int yyStart)
throws IOException {
Result yyResult;
Action<Node> yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Recursion>.
yyResult = pMultiplicativeOperator(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final String v$g$2 = yyResult.semanticValue();
yyResult = pUnaryExpression(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final Node v$g$3 = yyResult.semanticValue();
yyValue = new Action<Node>() {
public Node run(Node v$1) {
return GNode.create("MultiplicativeExpression", v$1, v$g$2, v$g$3);
}};
return yyResult.createValue(yyValue, yyError);
}
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.MultiplicativeOperator.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pMultiplicativeOperator(final int yyStart)
throws IOException {
Result yyResult;
String yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Times>.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue("*")) {
yyValue = "*";
return yyResult.createValue(yyValue, yyError);
}
// Alternative <Over>.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue("/")) {
yyValue = "/";
return yyResult.createValue(yyValue, yyError);
}
// Alternative <Modulo>.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue("%")) {
yyValue = "%";
return yyResult.createValue(yyValue, yyError);
}
// Done.
yyError = yyError.select("multiplicative operator expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.UnaryExpression.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pUnaryExpression(final int yyStart) throws IOException {
ExpressionRatsColumn yyColumn = (ExpressionRatsColumn)column(yyStart);
if (null == yyColumn.fUnaryExpression)
yyColumn.fUnaryExpression = pUnaryExpression$1(yyStart);
return yyColumn.fUnaryExpression;
}
/** Actually parse xtc.lang.cpp.Condition.UnaryExpression. */
private Result pUnaryExpression$1(final int yyStart) throws IOException {
Result yyResult;
int yyBase;
Node yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue("-")) {
yyResult = pUnaryExpression(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final Node v$g$1 = yyResult.semanticValue();
yyValue = GNode.create("UnaryMinusExpression", v$g$1);
yyValue.setLocation(location(yyStart));
return yyResult.createValue(yyValue, yyError);
}
}
// Alternative 2.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue("+")) {
yyResult = pUnaryExpression(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final Node v$g$1 = yyResult.semanticValue();
yyValue = GNode.create("UnaryPlusExpression", v$g$1);
yyValue.setLocation(location(yyStart));
return yyResult.createValue(yyValue, yyError);
}
}
// Alternative 3.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue("!")) {
yyResult = pUnaryExpression(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final Node v$g$1 = yyResult.semanticValue();
yyValue = GNode.create("LogicalNegationExpression", v$g$1);
yyValue.setLocation(location(yyStart));
return yyResult.createValue(yyValue, yyError);
}
}
// Alternative 4.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue("~")) {
yyResult = pUnaryExpression(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final Node v$g$1 = yyResult.semanticValue();
yyValue = GNode.create("BitwiseNegationExpression", v$g$1);
yyValue.setLocation(location(yyStart));
return yyResult.createValue(yyValue, yyError);
}
}
// Alternative 5.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue("defined")) {
final int yyChoice1 = yyResult.index;
// Nested alternative 1.
yyBase = yyChoice1;
yyResult = pSymbol(yyBase);
if (yyResult.hasValue("(")) {
yyResult = pPrimaryIdentifier(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final Node v$g$1 = yyResult.semanticValue();
yyBase = yyResult.index;
yyResult = pSymbol(yyBase);
if (yyResult.hasValue(")")) {
yyValue = GNode.create("DefinedExpression", v$g$1);
yyValue.setLocation(location(yyStart));
return yyResult.createValue(yyValue, yyError);
} else {
yyError = yyError.select("')' expected", yyBase);
}
}
} else {
yyError = yyError.select("'(' expected", yyBase);
}
// Nested alternative 2.
yyResult = pPrimaryIdentifier(yyChoice1);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final Node v$g$2 = yyResult.semanticValue();
yyValue = GNode.create("DefinedExpression", v$g$2);
yyValue.setLocation(location(yyStart));
return yyResult.createValue(yyValue, yyError);
}
}
// Alternative <Base>.
yyResult = pPrimaryExpression(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyValue = yyResult.semanticValue();
return yyResult.createValue(yyValue, yyError);
}
// Done.
yyError = yyError.select("unary expression expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.PrimaryExpression.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pPrimaryExpression(final int yyStart) throws IOException {
Result yyResult;
Result yyPredResult;
boolean yyPredMatched;
int yyBase;
Node yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative <Constant>.
yyResult = pCondition$Constant(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyValue = yyResult.semanticValue();
return yyResult.createValue(yyValue, yyError);
}
// Alternative 2.
yyPredMatched = false;
yyPredResult = pSymbol(yyStart);
if (yyPredResult.hasValue()) {
yyPredMatched = true;
}
if (! yyPredMatched) {
yyResult = pIdentifier(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final String v$g$1 = yyResult.semanticValue();
yyValue = GNode.create("PrimaryIdentifier", v$g$1);
yyValue.setLocation(location(yyStart));
return yyResult.createValue(yyValue, yyError);
}
} else {
yyError = yyError.select("primary expression expected", yyStart);
}
// Alternative <ParenthesizedExpression>.
yyResult = pSymbol(yyStart);
if (yyResult.hasValue("(")) {
yyResult = pConstantExpression(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyValue = yyResult.semanticValue();
yyBase = yyResult.index;
yyResult = pSymbol(yyBase);
if (yyResult.hasValue(")")) {
return yyResult.createValue(yyValue, yyError);
} else {
yyError = yyError.select("')' expected", yyBase);
}
}
}
// Done.
yyError = yyError.select("primary expression expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Condition.PrimaryIdentifier.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pPrimaryIdentifier(final int yyStart) throws IOException {
Result yyResult;
Result yyPredResult;
boolean yyPredMatched;
Node yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyPredMatched = false;
yyPredResult = pSymbol(yyStart);
if (yyPredResult.hasValue()) {
yyPredMatched = true;
}
if (! yyPredMatched) {
yyResult = pIdentifier(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
final String v$g$1 = yyResult.semanticValue();
yyValue = GNode.create("PrimaryIdentifier", v$g$1);
yyValue.setLocation(location(yyStart));
return yyResult.createValue(yyValue, yyError);
}
} else {
yyError = yyError.select("primary identifier expected", yyStart);
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Symbol.Symbol.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pSymbol(final int yyStart) throws IOException {
ExpressionRatsColumn yyColumn = (ExpressionRatsColumn)column(yyStart);
if (null == yyColumn.fSymbol) yyColumn.fSymbol = pSymbol$1(yyStart);
return yyColumn.fSymbol;
}
/** Actually parse xtc.lang.cpp.Symbol.Symbol. */
private Result pSymbol$1(final int yyStart) throws IOException {
Result yyResult;
String yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyResult = pSymbolCharacters(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyValue = yyResult.semanticValue();
yyResult = pSpacing(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
return yyResult.createValue(yyValue, yyError);
}
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Symbol.SymbolCharacters.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pSymbolCharacters(final int yyStart) throws IOException {
int yyC;
int yyIndex;
String yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyC = character(yyStart);
if (-1 != yyC) {
yyIndex = yyStart + 1;
switch (yyC) {
case '>':
{
final int yyChoice1 = yyIndex;
// Nested alternative 1.
yyC = character(yyChoice1);
if (-1 != yyC) {
yyIndex = yyChoice1 + 1;
switch (yyC) {
case '>':
{
final int yyChoice2 = yyIndex;
// Nested alternative 1.
yyC = character(yyChoice2);
if (-1 != yyC) {
yyIndex = yyChoice2 + 1;
if ('=' == yyC) {
yyValue = ">>=";
return new SemanticValue(yyValue, yyIndex, yyError);
}
}
// Nested alternative 2.
yyValue = ">>";
return new SemanticValue(yyValue, yyChoice2, yyError);
}
case '=':
{
yyValue = ">=";
return new SemanticValue(yyValue, yyIndex, yyError);
}
default:
/* No match. */
}
}
// Nested alternative 2.
yyValue = ">";
return new SemanticValue(yyValue, yyChoice1, yyError);
}
case '<':
{
final int yyChoice1 = yyIndex;
// Nested alternative 1.
yyC = character(yyChoice1);
if (-1 != yyC) {
yyIndex = yyChoice1 + 1;
switch (yyC) {
case '<':
{
final int yyChoice2 = yyIndex;
// Nested alternative 1.
yyC = character(yyChoice2);
if (-1 != yyC) {
yyIndex = yyChoice2 + 1;
if ('=' == yyC) {
yyValue = "<<=";
return new SemanticValue(yyValue, yyIndex, yyError);
}
}
// Nested alternative 2.
yyValue = "<<";
return new SemanticValue(yyValue, yyChoice2, yyError);
}
case '=':
{
yyValue = "<=";
return new SemanticValue(yyValue, yyIndex, yyError);
}
default:
/* No match. */
}
}
// Nested alternative 2.
yyValue = "<";
return new SemanticValue(yyValue, yyChoice1, yyError);
}
case '+':
{
final int yyChoice1 = yyIndex;
// Nested alternative 1.
yyC = character(yyChoice1);
if (-1 != yyC) {
yyIndex = yyChoice1 + 1;
switch (yyC) {
case '=':
{
yyValue = "+=";
return new SemanticValue(yyValue, yyIndex, yyError);
}
case '+':
{
yyValue = "++";
return new SemanticValue(yyValue, yyIndex, yyError);
}
default:
/* No match. */
}
}
// Nested alternative 2.
yyValue = "+";
return new SemanticValue(yyValue, yyChoice1, yyError);
}
case '-':
{
final int yyChoice1 = yyIndex;
// Nested alternative 1.
yyC = character(yyChoice1);
if (-1 != yyC) {
yyIndex = yyChoice1 + 1;
switch (yyC) {
case '=':
{
yyValue = "-=";
return new SemanticValue(yyValue, yyIndex, yyError);
}
case '-':
{
yyValue = "--";
return new SemanticValue(yyValue, yyIndex, yyError);
}
default:
/* No match. */
}
}
// Nested alternative 2.
yyValue = "-";
return new SemanticValue(yyValue, yyChoice1, yyError);
}
case '*':
{
final int yyChoice1 = yyIndex;
// Nested alternative 1.
yyC = character(yyChoice1);
if (-1 != yyC) {
yyIndex = yyChoice1 + 1;
if ('=' == yyC) {
yyValue = "*=";
return new SemanticValue(yyValue, yyIndex, yyError);
}
}
// Nested alternative 2.
yyValue = "*";
return new SemanticValue(yyValue, yyChoice1, yyError);
}
case '/':
{
final int yyChoice1 = yyIndex;
// Nested alternative 1.
yyC = character(yyChoice1);
if (-1 != yyC) {
yyIndex = yyChoice1 + 1;
if ('=' == yyC) {
yyValue = "/=";
return new SemanticValue(yyValue, yyIndex, yyError);
}
}
// Nested alternative 2.
yyValue = "/";
return new SemanticValue(yyValue, yyChoice1, yyError);
}
case '%':
{
final int yyChoice1 = yyIndex;
// Nested alternative 1.
yyC = character(yyChoice1);
if (-1 != yyC) {
yyIndex = yyChoice1 + 1;
if ('=' == yyC) {
yyValue = "%=";
return new SemanticValue(yyValue, yyIndex, yyError);
}
}
// Nested alternative 2.
yyValue = "%";
return new SemanticValue(yyValue, yyChoice1, yyError);
}
case '&':
{
final int yyChoice1 = yyIndex;
// Nested alternative 1.
yyC = character(yyChoice1);
if (-1 != yyC) {
yyIndex = yyChoice1 + 1;
switch (yyC) {
case '=':
{
yyValue = "&=";
return new SemanticValue(yyValue, yyIndex, yyError);
}
case '&':
{
yyValue = "&&";
return new SemanticValue(yyValue, yyIndex, yyError);
}
default:
/* No match. */
}
}
// Nested alternative 2.
yyValue = "&";
return new SemanticValue(yyValue, yyChoice1, yyError);
}
case '^':
{
final int yyChoice1 = yyIndex;
// Nested alternative 1.
yyC = character(yyChoice1);
if (-1 != yyC) {
yyIndex = yyChoice1 + 1;
if ('=' == yyC) {
yyValue = "^=";
return new SemanticValue(yyValue, yyIndex, yyError);
}
}
// Nested alternative 2.
yyValue = "^";
return new SemanticValue(yyValue, yyChoice1, yyError);
}
case '|':
{
final int yyChoice1 = yyIndex;
// Nested alternative 1.
yyC = character(yyChoice1);
if (-1 != yyC) {
yyIndex = yyChoice1 + 1;
switch (yyC) {
case '=':
{
yyValue = "|=";
return new SemanticValue(yyValue, yyIndex, yyError);
}
case '|':
{
yyValue = "||";
return new SemanticValue(yyValue, yyIndex, yyError);
}
default:
/* No match. */
}
}
// Nested alternative 2.
yyValue = "|";
return new SemanticValue(yyValue, yyChoice1, yyError);
}
case '=':
{
final int yyChoice1 = yyIndex;
// Nested alternative 1.
yyC = character(yyChoice1);
if (-1 != yyC) {
yyIndex = yyChoice1 + 1;
if ('=' == yyC) {
yyValue = "==";
return new SemanticValue(yyValue, yyIndex, yyError);
}
}
// Nested alternative 2.
yyValue = "=";
return new SemanticValue(yyValue, yyChoice1, yyError);
}
case '!':
{
final int yyChoice1 = yyIndex;
// Nested alternative 1.
yyC = character(yyChoice1);
if (-1 != yyC) {
yyIndex = yyChoice1 + 1;
if ('=' == yyC) {
yyValue = "!=";
return new SemanticValue(yyValue, yyIndex, yyError);
}
}
// Nested alternative 2.
yyValue = "!";
return new SemanticValue(yyValue, yyChoice1, yyError);
}
case '#':
{
final int yyChoice1 = yyIndex;
// Nested alternative 1.
yyC = character(yyChoice1);
if (-1 != yyC) {
yyIndex = yyChoice1 + 1;
if ('#' == yyC) {
yyValue = "##";
return new SemanticValue(yyValue, yyIndex, yyError);
}
}
// Nested alternative 2.
yyValue = "#";
return new SemanticValue(yyValue, yyChoice1, yyError);
}
case 'd':
{
yyC = character(yyIndex);
if (-1 != yyC) {
yyIndex = yyIndex + 1;
if ('e' == yyC) {
yyC = character(yyIndex);
if (-1 != yyC) {
yyIndex = yyIndex + 1;
if ('f' == yyC) {
yyC = character(yyIndex);
if (-1 != yyC) {
yyIndex = yyIndex + 1;
if ('i' == yyC) {
yyC = character(yyIndex);
if (-1 != yyC) {
yyIndex = yyIndex + 1;
if ('n' == yyC) {
yyC = character(yyIndex);
if (-1 != yyC) {
yyIndex = yyIndex + 1;
if ('e' == yyC) {
yyC = character(yyIndex);
if (-1 != yyC) {
yyIndex = yyIndex + 1;
if ('d' == yyC) {
yyValue = "defined";
return new SemanticValue(yyValue, yyIndex, yyError);
}
}
}
}
}
}
}
}
}
}
}
}
}
break;
case ';':
{
yyValue = ";";
return new SemanticValue(yyValue, yyIndex, yyError);
}
case ':':
{
yyValue = ":";
return new SemanticValue(yyValue, yyIndex, yyError);
}
case ',':
{
yyValue = ",";
return new SemanticValue(yyValue, yyIndex, yyError);
}
case '.':
{
yyValue = ".";
return new SemanticValue(yyValue, yyIndex, yyError);
}
case '{':
{
yyValue = "{";
return new SemanticValue(yyValue, yyIndex, yyError);
}
case '}':
{
yyValue = "}";
return new SemanticValue(yyValue, yyIndex, yyError);
}
case '(':
{
yyValue = "(";
return new SemanticValue(yyValue, yyIndex, yyError);
}
case ')':
{
yyValue = ")";
return new SemanticValue(yyValue, yyIndex, yyError);
}
case '[':
{
yyValue = "[";
return new SemanticValue(yyValue, yyIndex, yyError);
}
case ']':
{
yyValue = "]";
return new SemanticValue(yyValue, yyIndex, yyError);
}
case '~':
{
yyValue = "~";
return new SemanticValue(yyValue, yyIndex, yyError);
}
case '?':
{
yyValue = "?";
return new SemanticValue(yyValue, yyIndex, yyError);
}
default:
/* No match. */
}
}
// Done.
yyError = yyError.select("symbol characters expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Identifier.Identifier.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pIdentifier(final int yyStart) throws IOException {
int yyC;
Result yyResult;
int yyPredIndex;
boolean yyPredMatched;
String yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyResult = pWordCharacters(yyStart);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
yyValue = yyResult.semanticValue();
yyPredMatched = false;
yyC = character(yyResult.index);
if ('.' == yyC) {
yyPredIndex = yyResult.index + 1;
yyC = character(yyPredIndex);
if ('.' == yyC) {
yyPredIndex = yyPredIndex + 1;
yyC = character(yyPredIndex);
if ('.' == yyC) {
yyPredMatched = true;
}
}
}
if (! yyPredMatched) {
yyResult = pSpacing(yyResult.index);
yyError = yyResult.select(yyError);
if (yyResult.hasValue()) {
return yyResult.createValue(yyValue, yyError);
}
} else {
yyError = yyError.select("identifier expected", yyStart);
}
}
// Done.
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Identifier.WordCharacters.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pWordCharacters(final int yyStart) throws IOException {
int yyC;
int yyIndex;
int yyRepetition1;
String yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyC = character(yyStart);
if (-1 != yyC) {
yyIndex = yyStart + 1;
if ((('A' <= yyC) && (yyC <= 'Z')) ||
('_' == yyC) ||
(('a' <= yyC) && (yyC <= 'z'))) {
yyRepetition1 = yyIndex;
while (true) {
yyC = character(yyRepetition1);
if (-1 != yyC) {
yyIndex = yyRepetition1 + 1;
if ((('0' <= yyC) && (yyC <= '9')) ||
(('A' <= yyC) && (yyC <= 'Z')) ||
('_' == yyC) ||
(('a' <= yyC) && (yyC <= 'z'))) {
yyRepetition1 = yyIndex;
continue;
}
}
break;
}
yyValue = difference(yyStart, yyRepetition1);
return new SemanticValue(yyValue, yyRepetition1, yyError);
}
}
// Done.
yyError = yyError.select("word characters expected", yyStart);
return yyError;
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Spacing.Spacing.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pSpacing(final int yyStart) throws IOException {
int yyC;
int yyIndex;
Result yyResult;
Result yyPredResult;
boolean yyPredMatched;
int yyBase;
int yyRepetition1;
int yyRepetition2;
Void yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyRepetition1 = yyStart;
while (true) {
final int yyChoice1 = yyRepetition1;
// Nested alternative 1.
yyC = character(yyChoice1);
if (-1 != yyC) {
yyIndex = yyChoice1 + 1;
switch (yyC) {
case ' ':
{
yyRepetition1 = yyIndex;
continue;
}
case '\t':
{
yyRepetition1 = yyIndex;
continue;
}
case '\f':
{
yyRepetition1 = yyIndex;
continue;
}
case '\\':
{
yyResult = pLineTerminator(yyIndex);
yyError = yyResult.select(yyError, yyRepetition1);
if (yyResult.hasValue()) {
yyRepetition1 = yyResult.index;
continue;
}
}
break;
case '/':
{
yyC = character(yyIndex);
if (-1 != yyC) {
yyIndex = yyIndex + 1;
switch (yyC) {
case '*':
{
yyRepetition2 = yyIndex;
while (true) {
final int yyChoice2 = yyRepetition2;
// Nested alternative 1.
yyC = character(yyChoice2);
if (-1 != yyC) {
yyIndex = yyChoice2 + 1;
switch (yyC) {
case '*':
{
yyPredMatched = false;
yyC = character(yyIndex);
if ('/' == yyC) {
yyPredMatched = true;
}
if (! yyPredMatched) {
yyRepetition2 = yyIndex;
continue;
} else {
yyError = yyError.select("spacing expected", yyStart);
}
}
break;
default:
{
yyRepetition2 = yyIndex;
continue;
}
}
}
break;
}
yyBase = yyRepetition2;
yyC = character(yyBase);
if ('*' == yyC) {
yyIndex = yyRepetition2 + 1;
yyC = character(yyIndex);
if ('/' == yyC) {
yyIndex = yyIndex + 1;
yyRepetition1 = yyIndex;
continue;
} else {
yyError = yyError.select("'*/' expected", yyBase);
}
} else {
yyError = yyError.select("'*/' expected", yyBase);
}
}
break;
case '/':
{
yyRepetition2 = yyIndex;
while (true) {
yyC = character(yyRepetition2);
if (-1 != yyC) {
yyIndex = yyRepetition2 + 1;
switch (yyC) {
case '\n':
case '\r':
/* No match. */
break;
default:
{
yyRepetition2 = yyIndex;
continue;
}
}
}
break;
}
yyPredResult = pLineTerminator(yyRepetition2);
yyError = yyPredResult.select(yyError);
if (yyPredResult.hasValue()) {
yyRepetition1 = yyRepetition2;
continue;
}
}
break;
default:
/* No match. */
}
}
}
break;
default:
/* No match. */
}
}
break;
}
yyValue = null;
return new SemanticValue(yyValue, yyRepetition1, yyError);
}
// =========================================================================
/**
* Parse nonterminal xtc.lang.cpp.Spacing.LineTerminator.
*
* @param yyStart The index.
* @return The result.
* @throws IOException Signals an I/O error.
*/
private Result pLineTerminator(final int yyStart) throws IOException {
int yyC;
int yyIndex;
Void yyValue;
ParseError yyError = ParseError.DUMMY;
// Alternative 1.
yyC = character(yyStart);
if (-1 != yyC) {
yyIndex = yyStart + 1;
switch (yyC) {
case '\r':
{
final int yyChoice1 = yyIndex;
// Nested alternative 1.
yyC = character(yyChoice1);
if ('\n' == yyC) {
yyIndex = yyChoice1 + 1;
yyValue = null;
return new SemanticValue(yyValue, yyIndex, yyError);
}
// Nested alternative 2.
yyValue = null;
return new SemanticValue(yyValue, yyChoice1, yyError);
}
case '\n':
{
yyValue = null;
return new SemanticValue(yyValue, yyIndex, yyError);
}
default:
/* No match. */
}
}
// Done.
yyError = yyError.select("line terminator expected", yyStart);
return yyError;
}
// =========================================================================
static {
add(CPP_KEYWORDS, new String[] {
"define", "elif", "else", "endif", "error", "warning", "if", "ifdef",
"ifndef", "include", "include_next", "line", "pragma", "undef"
});
}
// =========================================================================
/**
* Get the specified text.
*
* @param s The text.
* @return The text.
*/
protected static final String toText(String s) {
return s;
}
// =========================================================================
/**
* Add the specified values to the specified set.
*
* @param set The set.
* @param values The new values.
*/
protected static final <T> void add(Set<T> set, T[] values) {
for (T v : values) set.add(v);
}
/**
* Check whether the specified set contains the specified value.
*
* @param set The set.
* @param value The value.
* @return <code>true</code> if the set contains the value.
*/
protected static final <T> boolean contains(Set<T> set, T value) {
return set.contains(value);
}
// =========================================================================
/**
* Parse the specified files.
*
* @param args The file names.
*/
public static void main(String[] args) {
if ((null == args) || (0 == args.length)) {
System.err.println("Usage: <file-name>+");
} else {
for (int i=0; i<args.length; i++) {
System.err.println("Processing " + args[i] + " ...");
Reader in = null;
try {
in = new BufferedReader(new FileReader(args[i]));
ExpressionRats p =
new ExpressionRats(in, args[i], (int)new File(args[i]).length());
Result r = p.pConstantExpression(0);
if (r.hasValue()) {
SemanticValue v = (SemanticValue)r;
if (v.value instanceof Node) {
Printer ptr = new
Printer(new BufferedWriter(new OutputStreamWriter(System.out)));
ptr.format((Node)v.value).pln().flush();
} else {
System.out.println(v.value.toString());
}
} else {
ParseError err = (ParseError)r;
if (-1 == err.index) {
System.err.println(" Parse error");
} else {
System.err.println(" " + p.location(err.index) + ": " + err.msg);
}
}
} catch (Throwable x) {
while (null != x.getCause()) {
x = x.getCause();
}
x.printStackTrace();
} finally {
try {
in.close();
} catch (Throwable x) {
/* Ignore. */
}
}
}
}
}
}