Package persistence.antlr

Examples of persistence.antlr.Token


 
  public final void line(
    ImportVocabTokenManager tm
  ) throws RecognitionException, TokenStreamException {
   
    Token  s1 = null;
    Token  lab = null;
    Token  s2 = null;
    Token  id = null;
    Token  para = null;
    Token  id2 = null;
    Token  i = null;
    Token t=null; Token s=null;
   
    try {      // for error handling
      {
      if ((LA(1)==STRING)) {
        s1 = LT(1);
        match(STRING);
        s = s1;
      }
      else if ((LA(1)==ID) && (LA(2)==ASSIGN) && (LA(3)==STRING)) {
        lab = LT(1);
        match(ID);
        t = lab;
        match(ASSIGN);
        s2 = LT(1);
        match(STRING);
        s = s2;
      }
      else if ((LA(1)==ID) && (LA(2)==LPAREN)) {
        id = LT(1);
        match(ID);
        t=id;
        match(LPAREN);
        para = LT(1);
        match(STRING);
        match(RPAREN);
      }
      else if ((LA(1)==ID) && (LA(2)==ASSIGN) && (LA(3)==INT)) {
        id2 = LT(1);
        match(ID);
        t=id2;
      }
      else {
        throw new NoViableAltException(LT(1), getFilename());
      }
     
      }
      match(ASSIGN);
      i = LT(1);
      match(INT);
     
          Integer value = Integer.valueOf(i.getText());
          // if literal found, define as a string literal
          if ( s!=null ) {
            tm.define(s.getText(), value.intValue());
            // if label, then label the string and map label to token symbol also
            if ( t!=null ) {
              StringLiteralSymbol sl =
                (StringLiteralSymbol) tm.getTokenSymbol(s.getText());
              sl.setLabel(t.getText());
              tm.mapToTokenSymbol(t.getText(), sl);
            }
          }
          // define token (not a literal)
View Full Code Here


  public final void grammarFile(
    Hierarchy hier, String file
  ) throws RecognitionException, TokenStreamException {
   
    Token  hdr = null;
   
      Grammar gr;
      IndexedVector opt=null;
   
   
    try {      // for error handling
      {
      _loop265:
      do {
        if ((LA(1)==HEADER_ACTION)) {
          hdr = LT(1);
          match(HEADER_ACTION);
          hier.getFile(file).addHeaderAction(hdr.getText());
        }
        else {
          break _loop265;
        }
       
View Full Code Here

  public final IndexedVector  optionSpec(
    Grammar gr
  ) throws RecognitionException, TokenStreamException {
    IndexedVector options;
   
    Token  op = null;
    Token  rhs = null;
   
      options = new IndexedVector();
   
   
    try {      // for error handling
      match(OPTIONS_START);
      {
      _loop280:
      do {
        if ((LA(1)==ID)) {
          op = LT(1);
          match(ID);
          rhs = LT(1);
          match(ASSIGN_RHS);
         
                  Option newOp = new Option(op.getText(),rhs.getText(),gr);
                  options.appendElement(newOp.getName(),newOp);
                  if ( gr!=null && op.getText().equals("importVocab") ) {
                    gr.specifiedVocabulary = true;
                    gr.importVocab = rhs.getText();
                  }
                  else if ( gr!=null && op.getText().equals("exportVocab") ) {
                    // don't want ';' included in outputVocab.
                    // This is heinously inconsistent!  Ugh.
                    gr.exportVocab = rhs.getText().substring(0,rhs.getText().length()-1);
                    gr.exportVocab = gr.exportVocab.trim();
                  }
                 
        }
        else {
View Full Code Here

  public final Grammar  class_def(
    String file, Hierarchy hier
  ) throws RecognitionException, TokenStreamException {
    Grammar gr;
   
    Token  preamble = null;
    Token  sub = null;
    Token  sup = null;
    Token  tk = null;
    Token  memberA = null;
   
      gr=null;
      IndexedVector rules = new IndexedVector(100);
      IndexedVector classOptions = null;
      String sc = null;
   
   
    try {      // for error handling
      {
      switch ( LA(1)) {
      case ACTION:
      {
        preamble = LT(1);
        match(ACTION);
        break;
      }
      case LITERAL_class:
      {
        break;
      }
      default:
      {
        throw new NoViableAltException(LT(1), getFilename());
      }
      }
      }
      match(LITERAL_class);
      sub = LT(1);
      match(ID);
      match(LITERAL_extends);
      sup = LT(1);
      match(ID);
      {
      switch ( LA(1)) {
      case SUBRULE_BLOCK:
      {
        sc=superClass();
        break;
      }
      case SEMI:
      {
        break;
      }
      default:
      {
        throw new NoViableAltException(LT(1), getFilename());
      }
      }
      }
      match(SEMI);
     
            gr = (Grammar)hier.getGrammar(sub.getText());
            if ( gr!=null ) {
      //        antlr.Tool.toolError("redefinition of grammar "+gr.getName()+" ignored");
              gr=null;
              throw new SemanticException("redefinition of grammar "+sub.getText(), file, sub.getLine(), sub.getColumn());
            }
            else {
              gr = new Grammar(hier.getTool(), sub.getText(), sup.getText(), rules);
              gr.superClass=sc;
              if ( preamble!=null ) {
                gr.setPreambleAction(preamble.getText());
              }
            }
         
      {
      switch ( LA(1)) {
      case OPTIONS_START:
      {
        classOptions=optionSpec(gr);
        break;
      }
      case ACTION:
      case ID:
      case TOKENS_SPEC:
      case LITERAL_protected:
      case LITERAL_private:
      case LITERAL_public:
      {
        break;
      }
      default:
      {
        throw new NoViableAltException(LT(1), getFilename());
      }
      }
      }
     
          if ( gr!=null ) {
            gr.setOptions(classOptions);
          }
         
      {
      switch ( LA(1)) {
      case TOKENS_SPEC:
      {
        tk = LT(1);
        match(TOKENS_SPEC);
        gr.setTokenSection(tk.getText());
        break;
      }
      case ACTION:
      case ID:
      case LITERAL_protected:
      case LITERAL_private:
      case LITERAL_public:
      {
        break;
      }
      default:
      {
        throw new NoViableAltException(LT(1), getFilename());
      }
      }
      }
      {
      switch ( LA(1)) {
      case ACTION:
      {
        memberA = LT(1);
        match(ACTION);
        gr.setMemberAction(memberA.getText());
        break;
      }
      case ID:
      case LITERAL_protected:
      case LITERAL_private:
View Full Code Here

 
  public final void rule(
    Grammar gr
  ) throws RecognitionException, TokenStreamException {
   
    Token  r = null;
    Token  arg = null;
    Token  ret = null;
    Token  init = null;
    Token  blk = null;
   
      IndexedVector o = null// options for rule
      String vis = null;
      boolean bang=false;
      String eg=null, thr="";
   
   
    try {      // for error handling
      {
      switch ( LA(1)) {
      case LITERAL_protected:
      {
        match(LITERAL_protected);
        vis="protected";
        break;
      }
      case LITERAL_private:
      {
        match(LITERAL_private);
        vis="private";
        break;
      }
      case LITERAL_public:
      {
        match(LITERAL_public);
        vis="public";
        break;
      }
      case ID:
      {
        break;
      }
      default:
      {
        throw new NoViableAltException(LT(1), getFilename());
      }
      }
      }
      r = LT(1);
      match(ID);
      {
      switch ( LA(1)) {
      case BANG:
      {
        match(BANG);
        bang=true;
        break;
      }
      case ACTION:
      case OPTIONS_START:
      case ARG_ACTION:
      case LITERAL_returns:
      case RULE_BLOCK:
      case LITERAL_throws:
      {
        break;
      }
      default:
      {
        throw new NoViableAltException(LT(1), getFilename());
      }
      }
      }
      {
      switch ( LA(1)) {
      case ARG_ACTION:
      {
        arg = LT(1);
        match(ARG_ACTION);
        break;
      }
      case ACTION:
      case OPTIONS_START:
      case LITERAL_returns:
      case RULE_BLOCK:
      case LITERAL_throws:
      {
        break;
      }
      default:
      {
        throw new NoViableAltException(LT(1), getFilename());
      }
      }
      }
      {
      switch ( LA(1)) {
      case LITERAL_returns:
      {
        match(LITERAL_returns);
        ret = LT(1);
        match(ARG_ACTION);
        break;
      }
      case ACTION:
      case OPTIONS_START:
      case RULE_BLOCK:
      case LITERAL_throws:
      {
        break;
      }
      default:
      {
        throw new NoViableAltException(LT(1), getFilename());
      }
      }
      }
      {
      switch ( LA(1)) {
      case LITERAL_throws:
      {
        thr=throwsSpec();
        break;
      }
      case ACTION:
      case OPTIONS_START:
      case RULE_BLOCK:
      {
        break;
      }
      default:
      {
        throw new NoViableAltException(LT(1), getFilename());
      }
      }
      }
      {
      switch ( LA(1)) {
      case OPTIONS_START:
      {
        o=optionSpec(null);
        break;
      }
      case ACTION:
      case RULE_BLOCK:
      {
        break;
      }
      default:
      {
        throw new NoViableAltException(LT(1), getFilename());
      }
      }
      }
      {
      switch ( LA(1)) {
      case ACTION:
      {
        init = LT(1);
        match(ACTION);
        break;
      }
      case RULE_BLOCK:
      {
        break;
      }
      default:
      {
        throw new NoViableAltException(LT(1), getFilename());
      }
      }
      }
      blk = LT(1);
      match(RULE_BLOCK);
      eg=exceptionGroup();
     
          String rtext = blk.getText()+eg;
          Rule ppr = new Rule(r.getText(),rtext,o,gr);
          ppr.setThrowsSpec(thr);
          if ( arg!=null ) {
            ppr.setArgs(arg.getText());
          }
View Full Code Here

  }
 
  public final String  throwsSpec() throws RecognitionException, TokenStreamException {
    String t;
   
    Token  a = null;
    Token  b = null;
    t="throws ";
   
    try {      // for error handling
      match(LITERAL_throws);
      a = LT(1);
      match(ID);
      t+=a.getText();
      {
      _loop291:
      do {
        if ((LA(1)==COMMA)) {
          match(COMMA);
          b = LT(1);
          match(ID);
          t+=","+b.getText();
        }
        else {
          break _loop291;
        }
       
View Full Code Here

  }
 
  public final String  exceptionSpec() throws RecognitionException, TokenStreamException {
    String es;
   
    Token  aa = null;
    String h=null;
    es = System.getProperty("line.separator")+"exception ";
   
   
    try {      // for error handling
      match(LITERAL_exception);
      {
      switch ( LA(1)) {
      case ARG_ACTION:
      {
        aa = LT(1);
        match(ARG_ACTION);
        es += aa.getText();
        break;
      }
      case EOF:
      case ACTION:
      case LITERAL_class:
View Full Code Here

  }
 
  public final String  exceptionHandler() throws RecognitionException, TokenStreamException {
    String h;
   
    Token  a1 = null;
    Token  a2 = null;
    h=null;
   
    try {      // for error handling
      match(LITERAL_catch);
      a1 = LT(1);
      match(ARG_ACTION);
      a2 = LT(1);
      match(ACTION);
      h = System.getProperty("line.separator")+
             "catch "+a1.getText()+" "+a2.getText();
    }
    catch (RecognitionException ex) {
      reportError(ex);
      consume();
      consumeUntil(_tokenSet_8);
View Full Code Here

  tokenNames = _tokenNames;
}

  public final void grammar() throws RecognitionException, TokenStreamException {
   
    Token  n = null;
    Token  h = null;
   
    try {      // for error handling
      {
      _loop4:
      do {
View Full Code Here

    }
  }
 
  public final void fileOptionsSpec() throws RecognitionException, TokenStreamException {
   
    Token idTok; Token value;
   
    match(OPTIONS);
    {
    _loop18:
    do {
View Full Code Here

TOP

Related Classes of persistence.antlr.Token

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.