Android Open Source - splott Surface Parser






From Project

Back to project page splott.

License

The source code is released under:

MIT License

If you think the Android project splott listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

// Generated from Surface.g4 by ANTLR 4.2.2
//  w  w  w  .ja v  a 2  s .  c o  m
package com.wordsaretoys.splott.parser;

import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.misc.*;
import org.antlr.v4.runtime.tree.*;
import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;

@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
public class SurfaceParser extends Parser {
  protected static final DFA[] _decisionToDFA;
  protected static final PredictionContextCache _sharedContextCache =
    new PredictionContextCache();
  public static final int
    T__1=1, T__0=2, VARIABLE=3, FUNCTION=4, ADD=5, SUB=6, MUL=7, DIV=8, POW=9, 
    EQU=10, NUMBER=11, WS=12;
  public static final String[] tokenNames = {
    "<INVALID>", "')'", "'('", "VARIABLE", "FUNCTION", "'+'", "'-'", "'*'", 
    "'/'", "'**'", "'='", "NUMBER", "WS"
  };
  public static final int
    RULE_surface = 0, RULE_expr = 1;
  public static final String[] ruleNames = {
    "surface", "expr"
  };

  @Override
  public String getGrammarFileName() { return "Surface.g4"; }

  @Override
  public String[] getTokenNames() { return tokenNames; }

  @Override
  public String[] getRuleNames() { return ruleNames; }

  @Override
  public String getSerializedATN() { return _serializedATN; }

  @Override
  public ATN getATN() { return _ATN; }

  public SurfaceParser(TokenStream input) {
    super(input);
    _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
  }
  public static class SurfaceContext extends ParserRuleContext {
    public ExprContext expr() {
      return getRuleContext(ExprContext.class,0);
    }
    public SurfaceContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }
    @Override public int getRuleIndex() { return RULE_surface; }
    @Override
    public void enterRule(ParseTreeListener listener) {
      if ( listener instanceof SurfaceListener ) ((SurfaceListener)listener).enterSurface(this);
    }
    @Override
    public void exitRule(ParseTreeListener listener) {
      if ( listener instanceof SurfaceListener ) ((SurfaceListener)listener).exitSurface(this);
    }
  }

  public final SurfaceContext surface() throws RecognitionException {
    SurfaceContext _localctx = new SurfaceContext(_ctx, getState());
    enterRule(_localctx, 0, RULE_surface);
    try {
      enterOuterAlt(_localctx, 1);
      {
      setState(4); expr(0);
      }
    }
    catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    }
    finally {
      exitRule();
    }
    return _localctx;
  }

  public static class ExprContext extends ParserRuleContext {
    public ExprContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }
    @Override public int getRuleIndex() { return RULE_expr; }
   
    public ExprContext() { }
    public void copyFrom(ExprContext ctx) {
      super.copyFrom(ctx);
    }
  }
  public static class MuldivExprContext extends ExprContext {
    public TerminalNode MUL() { return getToken(SurfaceParser.MUL, 0); }
    public TerminalNode DIV() { return getToken(SurfaceParser.DIV, 0); }
    public List<ExprContext> expr() {
      return getRuleContexts(ExprContext.class);
    }
    public ExprContext expr(int i) {
      return getRuleContext(ExprContext.class,i);
    }
    public MuldivExprContext(ExprContext ctx) { copyFrom(ctx); }
    @Override
    public void enterRule(ParseTreeListener listener) {
      if ( listener instanceof SurfaceListener ) ((SurfaceListener)listener).enterMuldivExpr(this);
    }
    @Override
    public void exitRule(ParseTreeListener listener) {
      if ( listener instanceof SurfaceListener ) ((SurfaceListener)listener).exitMuldivExpr(this);
    }
  }
  public static class NumExprContext extends ExprContext {
    public TerminalNode NUMBER() { return getToken(SurfaceParser.NUMBER, 0); }
    public NumExprContext(ExprContext ctx) { copyFrom(ctx); }
    @Override
    public void enterRule(ParseTreeListener listener) {
      if ( listener instanceof SurfaceListener ) ((SurfaceListener)listener).enterNumExpr(this);
    }
    @Override
    public void exitRule(ParseTreeListener listener) {
      if ( listener instanceof SurfaceListener ) ((SurfaceListener)listener).exitNumExpr(this);
    }
  }
  public static class EqualsExprContext extends ExprContext {
    public List<ExprContext> expr() {
      return getRuleContexts(ExprContext.class);
    }
    public TerminalNode EQU() { return getToken(SurfaceParser.EQU, 0); }
    public ExprContext expr(int i) {
      return getRuleContext(ExprContext.class,i);
    }
    public EqualsExprContext(ExprContext ctx) { copyFrom(ctx); }
    @Override
    public void enterRule(ParseTreeListener listener) {
      if ( listener instanceof SurfaceListener ) ((SurfaceListener)listener).enterEqualsExpr(this);
    }
    @Override
    public void exitRule(ParseTreeListener listener) {
      if ( listener instanceof SurfaceListener ) ((SurfaceListener)listener).exitEqualsExpr(this);
    }
  }
  public static class ParensExprContext extends ExprContext {
    public ExprContext expr() {
      return getRuleContext(ExprContext.class,0);
    }
    public ParensExprContext(ExprContext ctx) { copyFrom(ctx); }
    @Override
    public void enterRule(ParseTreeListener listener) {
      if ( listener instanceof SurfaceListener ) ((SurfaceListener)listener).enterParensExpr(this);
    }
    @Override
    public void exitRule(ParseTreeListener listener) {
      if ( listener instanceof SurfaceListener ) ((SurfaceListener)listener).exitParensExpr(this);
    }
  }
  public static class VarExprContext extends ExprContext {
    public TerminalNode VARIABLE() { return getToken(SurfaceParser.VARIABLE, 0); }
    public VarExprContext(ExprContext ctx) { copyFrom(ctx); }
    @Override
    public void enterRule(ParseTreeListener listener) {
      if ( listener instanceof SurfaceListener ) ((SurfaceListener)listener).enterVarExpr(this);
    }
    @Override
    public void exitRule(ParseTreeListener listener) {
      if ( listener instanceof SurfaceListener ) ((SurfaceListener)listener).exitVarExpr(this);
    }
  }
  public static class FuncExprContext extends ExprContext {
    public ExprContext expr() {
      return getRuleContext(ExprContext.class,0);
    }
    public TerminalNode FUNCTION() { return getToken(SurfaceParser.FUNCTION, 0); }
    public FuncExprContext(ExprContext ctx) { copyFrom(ctx); }
    @Override
    public void enterRule(ParseTreeListener listener) {
      if ( listener instanceof SurfaceListener ) ((SurfaceListener)listener).enterFuncExpr(this);
    }
    @Override
    public void exitRule(ParseTreeListener listener) {
      if ( listener instanceof SurfaceListener ) ((SurfaceListener)listener).exitFuncExpr(this);
    }
  }
  public static class AddsubExprContext extends ExprContext {
    public List<ExprContext> expr() {
      return getRuleContexts(ExprContext.class);
    }
    public ExprContext expr(int i) {
      return getRuleContext(ExprContext.class,i);
    }
    public TerminalNode SUB() { return getToken(SurfaceParser.SUB, 0); }
    public TerminalNode ADD() { return getToken(SurfaceParser.ADD, 0); }
    public AddsubExprContext(ExprContext ctx) { copyFrom(ctx); }
    @Override
    public void enterRule(ParseTreeListener listener) {
      if ( listener instanceof SurfaceListener ) ((SurfaceListener)listener).enterAddsubExpr(this);
    }
    @Override
    public void exitRule(ParseTreeListener listener) {
      if ( listener instanceof SurfaceListener ) ((SurfaceListener)listener).exitAddsubExpr(this);
    }
  }
  public static class UminusExprContext extends ExprContext {
    public ExprContext expr() {
      return getRuleContext(ExprContext.class,0);
    }
    public TerminalNode SUB() { return getToken(SurfaceParser.SUB, 0); }
    public UminusExprContext(ExprContext ctx) { copyFrom(ctx); }
    @Override
    public void enterRule(ParseTreeListener listener) {
      if ( listener instanceof SurfaceListener ) ((SurfaceListener)listener).enterUminusExpr(this);
    }
    @Override
    public void exitRule(ParseTreeListener listener) {
      if ( listener instanceof SurfaceListener ) ((SurfaceListener)listener).exitUminusExpr(this);
    }
  }
  public static class ExpExprContext extends ExprContext {
    public List<ExprContext> expr() {
      return getRuleContexts(ExprContext.class);
    }
    public ExprContext expr(int i) {
      return getRuleContext(ExprContext.class,i);
    }
    public TerminalNode POW() { return getToken(SurfaceParser.POW, 0); }
    public ExpExprContext(ExprContext ctx) { copyFrom(ctx); }
    @Override
    public void enterRule(ParseTreeListener listener) {
      if ( listener instanceof SurfaceListener ) ((SurfaceListener)listener).enterExpExpr(this);
    }
    @Override
    public void exitRule(ParseTreeListener listener) {
      if ( listener instanceof SurfaceListener ) ((SurfaceListener)listener).exitExpExpr(this);
    }
  }

  public final ExprContext expr() throws RecognitionException {
    return expr(0);
  }

  private ExprContext expr(int _p) throws RecognitionException {
    ParserRuleContext _parentctx = _ctx;
    int _parentState = getState();
    ExprContext _localctx = new ExprContext(_ctx, _parentState);
    ExprContext _prevctx = _localctx;
    int _startState = 2;
    enterRecursionRule(_localctx, 2, RULE_expr, _p);
    int _la;
    try {
      int _alt;
      enterOuterAlt(_localctx, 1);
      {
      setState(20);
      switch (_input.LA(1)) {
      case SUB:
        {
        _localctx = new UminusExprContext(_localctx);
        _ctx = _localctx;
        _prevctx = _localctx;

        setState(7); match(SUB);
        setState(8); expr(7);
        }
        break;
      case NUMBER:
        {
        _localctx = new NumExprContext(_localctx);
        _ctx = _localctx;
        _prevctx = _localctx;
        setState(9); match(NUMBER);
        }
        break;
      case VARIABLE:
        {
        _localctx = new VarExprContext(_localctx);
        _ctx = _localctx;
        _prevctx = _localctx;
        setState(10); match(VARIABLE);
        }
        break;
      case FUNCTION:
        {
        _localctx = new FuncExprContext(_localctx);
        _ctx = _localctx;
        _prevctx = _localctx;
        setState(11); match(FUNCTION);
        setState(12); match(2);
        setState(13); expr(0);
        setState(14); match(1);
        }
        break;
      case 2:
        {
        _localctx = new ParensExprContext(_localctx);
        _ctx = _localctx;
        _prevctx = _localctx;
        setState(16); match(2);
        setState(17); expr(0);
        setState(18); match(1);
        }
        break;
      default:
        throw new NoViableAltException(this);
      }
      _ctx.stop = _input.LT(-1);
      setState(36);
      _errHandler.sync(this);
      _alt = getInterpreter().adaptivePredict(_input,2,_ctx);
      while ( _alt!=2 && _alt!=ATN.INVALID_ALT_NUMBER ) {
        if ( _alt==1 ) {
          if ( _parseListeners!=null ) triggerExitRuleEvent();
          _prevctx = _localctx;
          {
          setState(34);
          switch ( getInterpreter().adaptivePredict(_input,1,_ctx) ) {
          case 1:
            {
            _localctx = new MuldivExprContext(new ExprContext(_parentctx, _parentState));
            pushNewRecursionContext(_localctx, _startState, RULE_expr);
            setState(22);
            if (!(precpred(_ctx, 6))) throw new FailedPredicateException(this, "precpred(_ctx, 6)");
            setState(23);
            _la = _input.LA(1);
            if ( !(_la==MUL || _la==DIV) ) {
            _errHandler.recoverInline(this);
            }
            consume();
            setState(24); expr(7);
            }
            break;

          case 2:
            {
            _localctx = new AddsubExprContext(new ExprContext(_parentctx, _parentState));
            pushNewRecursionContext(_localctx, _startState, RULE_expr);
            setState(25);
            if (!(precpred(_ctx, 5))) throw new FailedPredicateException(this, "precpred(_ctx, 5)");
            setState(26);
            _la = _input.LA(1);
            if ( !(_la==ADD || _la==SUB) ) {
            _errHandler.recoverInline(this);
            }
            consume();
            setState(27); expr(6);
            }
            break;

          case 3:
            {
            _localctx = new ExpExprContext(new ExprContext(_parentctx, _parentState));
            pushNewRecursionContext(_localctx, _startState, RULE_expr);
            setState(28);
            if (!(precpred(_ctx, 4))) throw new FailedPredicateException(this, "precpred(_ctx, 4)");
            setState(29); match(POW);
            setState(30); expr(5);
            }
            break;

          case 4:
            {
            _localctx = new EqualsExprContext(new ExprContext(_parentctx, _parentState));
            pushNewRecursionContext(_localctx, _startState, RULE_expr);
            setState(31);
            if (!(precpred(_ctx, 1))) throw new FailedPredicateException(this, "precpred(_ctx, 1)");
            setState(32); match(EQU);
            setState(33); expr(2);
            }
            break;
          }
          } 
        }
        setState(38);
        _errHandler.sync(this);
        _alt = getInterpreter().adaptivePredict(_input,2,_ctx);
      }
      }
    }
    catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    }
    finally {
      unrollRecursionContexts(_parentctx);
    }
    return _localctx;
  }

  public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
    switch (ruleIndex) {
    case 1: return expr_sempred((ExprContext)_localctx, predIndex);
    }
    return true;
  }
  private boolean expr_sempred(ExprContext _localctx, int predIndex) {
    switch (predIndex) {
    case 0: return precpred(_ctx, 6);

    case 1: return precpred(_ctx, 5);

    case 2: return precpred(_ctx, 4);

    case 3: return precpred(_ctx, 1);
    }
    return true;
  }

  public static final String _serializedATN =
    "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3\16*\4\2\t\2\4\3\t"+
    "\3\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\5\3"+
    "\27\n\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\7\3%\n\3\f\3\16"+
    "\3(\13\3\3\3\2\3\4\4\2\4\2\4\3\2\t\n\3\2\7\b/\2\6\3\2\2\2\4\26\3\2\2\2"+
    "\6\7\5\4\3\2\7\3\3\2\2\2\b\t\b\3\1\2\t\n\7\b\2\2\n\27\5\4\3\t\13\27\7"+
    "\r\2\2\f\27\7\5\2\2\r\16\7\6\2\2\16\17\7\4\2\2\17\20\5\4\3\2\20\21\7\3"+
    "\2\2\21\27\3\2\2\2\22\23\7\4\2\2\23\24\5\4\3\2\24\25\7\3\2\2\25\27\3\2"+
    "\2\2\26\b\3\2\2\2\26\13\3\2\2\2\26\f\3\2\2\2\26\r\3\2\2\2\26\22\3\2\2"+
    "\2\27&\3\2\2\2\30\31\f\b\2\2\31\32\t\2\2\2\32%\5\4\3\t\33\34\f\7\2\2\34"+
    "\35\t\3\2\2\35%\5\4\3\b\36\37\f\6\2\2\37 \7\13\2\2 %\5\4\3\7!\"\f\3\2"+
    "\2\"#\7\f\2\2#%\5\4\3\4$\30\3\2\2\2$\33\3\2\2\2$\36\3\2\2\2$!\3\2\2\2"+
    "%(\3\2\2\2&$\3\2\2\2&\'\3\2\2\2\'\5\3\2\2\2(&\3\2\2\2\5\26$&";
  public static final ATN _ATN =
    new ATNDeserializer().deserialize(_serializedATN.toCharArray());
  static {
    _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
    for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
      _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
    }
  }
}




Java Source Code List

com.wordsaretoys.rise.geometry.Camera.java
com.wordsaretoys.rise.geometry.Geom.java
com.wordsaretoys.rise.geometry.Mote.java
com.wordsaretoys.rise.geometry.Ortho.java
com.wordsaretoys.rise.geometry.Quaternion.java
com.wordsaretoys.rise.geometry.Vector.java
com.wordsaretoys.rise.glwrapper.Mesh.java
com.wordsaretoys.rise.glwrapper.Shader.java
com.wordsaretoys.rise.glwrapper.Texture.java
com.wordsaretoys.rise.meshutil.HeightMapper.java
com.wordsaretoys.rise.meshutil.IndexBuffer.java
com.wordsaretoys.rise.meshutil.SurfaceMapper.java
com.wordsaretoys.rise.meshutil.VertexBuffer.java
com.wordsaretoys.rise.meshutil.Vindexer.java
com.wordsaretoys.rise.pattern.Bitmap.java
com.wordsaretoys.rise.pattern.F2FSumMap.java
com.wordsaretoys.rise.pattern.I2FCutMap.java
com.wordsaretoys.rise.pattern.I2FMap.java
com.wordsaretoys.rise.pattern.I2IMap.java
com.wordsaretoys.rise.pattern.Pattern.java
com.wordsaretoys.rise.pattern.Ring.java
com.wordsaretoys.rise.utility.Asset.java
com.wordsaretoys.rise.utility.Board.java
com.wordsaretoys.rise.utility.Dbg.java
com.wordsaretoys.rise.utility.Interval.java
com.wordsaretoys.rise.utility.Misc.java
com.wordsaretoys.rise.utility.Needle.java
com.wordsaretoys.splott.MainActivity.java
com.wordsaretoys.splott.parser.Compiler.java
com.wordsaretoys.splott.parser.SurfaceBaseListener.java
com.wordsaretoys.splott.parser.SurfaceLexer.java
com.wordsaretoys.splott.parser.SurfaceListener.java
com.wordsaretoys.splott.parser.SurfaceParser.java
com.wordsaretoys.splott.parser.SyntaxChecker.java
com.wordsaretoys.splott.parser.Vm.java
com.wordsaretoys.splott.plotter.GlView.java
com.wordsaretoys.splott.plotter.Render.java
com.wordsaretoys.splott.plotter.Surface.java