no_viable_alt_exception.sa

来自「SRI international 发布的OAA框架软件」· SA 代码 · 共 62 行

SA
62
字号
(* 

  ANTLR Translator Generator
  Project led by Terence Parr at http://www.jGuru.com
  Software rights: http://www.antlr.org/RIGHTS.html
 
  $Id: no_viable_alt_exception.sa,v 1.1.1.1 2002/01/02 19:59:09 agno Exp $

*)

class ANTLR_NO_VIABLE_ALT_EXCEPTION{AST < $ANTLR_AST{AST} } < $ANTLR_RECOGNITION_EXCEPTION is

   include ANTLR_RECOGNITION_EXCEPTION 
	 str     -> super_str, 
	 message -> super_message;

   attr token : $ANTLR_TOKEN;
   attr node : AST;	-- handles parsing and treeparsing
   readonly attr line : INT;
   readonly attr column : INT;   

   create( t : AST ) : SAME is
      res : SAME := #SAME("NoViableAlt");
      res.node := t;
      res.file_name := "<AST>";
      return res;
   end;

   create_from_token( t : $ANTLR_TOKEN , fn : STR ) : SAME is
      res : SAME := #SAME("NoViableAlt");
      res.token := t;
      res.line := t.line;
      res.column := t.column;
      res.file_name := fn;
      return res;
   end;

   -- Returns a clean error message (no line number/column information)
   message : STR is
      if ( ~void(token) ) then
	 return "unexpected token: " + token.text;
      end;

      -- must be a tree parser error if void(token)
      if ( SYS::is_eq( node , AST::ASTNULL ) ) then
	 return "unexpected end of subtree";
      end;

      return "unexpected AST node: " + node.str;
   end;

   -- Returns a string representation of this exception.
   str : STR is
      if ( ~void(token) ) then
	 return file_line_str + message;
      end;
      
      return message;
   end;

end;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?