token_stream_basic_filter.sa

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

SA
41
字号
(* 

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

*)

class ANTLR_TOKEN_STREAM_BASIC_FILTER{ TOKEN < $ANTLR_TOKEN } < $ANTLR_TOKEN_STREAM{ TOKEN } is
   
   -- the set of token types to discard
   attr discard_set : INT_SET;

   -- the input stream
   private attr input : $ANTLR_TOKEN_STREAM{TOKEN};
   
   discard_type( ttype : INT ) is
      discard_set := discard_set.insert( ttype );
   end;
   
   create( input : $ANTLR_TOKEN_STREAM{TOKEN} ) : SAME is
      res : SAME := new;
      res.input := input;
      res.discard_set := #INT_SET;
      return res;
   end;

   next_token : TOKEN is

      tok : TOKEN := input.next_token;
      loop while!( ~void(tok) and discard_set.member( tok.ttype ) );
	 tok := input.next_token;
      end;
      return tok;

   end;
   
end;

⌨️ 快捷键说明

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