<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    VIRGIN FOREST OF JAVA
    不要埋頭苦干,要學(xué)習(xí),學(xué)習(xí),再學(xué)習(xí)。。。。。
    powered by R.Zeus
    Author Terence Parr ?PREMIUM

    ?????????????????????????????????Created?? Sep 3, 1999


    ?

    ?

    Answer
    A lexer is a TokenStream source that merely spits out a stream of Token objects to the parser (or another stream consumer). As such, a lexer implements method nextToken() to satisfy interface TokenStream. The parser repeatedly calls yourlexer.nextToken() to get tokens.

    What token definitions result in token objects that get sent to the parser? The answer you'd expect or the one you're used to is, "You get a Token object for every lexical rule in your lexer grammar." This is indeed the default case for ANTLR's lexer grammars.

    What if you want to break up the definition of a complicated rule into multiple rules? Surely you don't want every rule to result in a complete Token object in this case. Some rules are only around to help other rules construct tokens. To distinguish these "helper" rules from rules that result in tokens, use the protected modifier. This overloading of the access-visibility Java term occurs because if the rule is not visible, it cannot be "seen" by the parser.

    Another, more practical, way to look at this is to note that only non-protected rules get called by nextToken() and, hence, only non-protected rules can generate tokens that get shoved down the TokenStream pipe to the parser.

    I now recognize this approach as a mistake. I have a number of other proposals to fix this, none that seems to satisfy everyone.

    								class L extends Lexer;
    
    /** This rule is "visible" to the parser
     *  and a Token object is sent to the
     *  parser when an INT is matched.
     */
    INT : (DIGIT)+ ;
    
    
    /** This rule does not result in a token
     *  object that is passed to the parser.
     *  It merely recognizes a portion of INT.
     */
    protected
    DIGIT : '0'..'9' ;
    
    						

    By definition, all lexical rules return Token objects (ANTLR optimizes away many of these object creations, however), but only the Token objects of non-protected rules get pulled out of the lexer itself

    posted on 2006-09-06 17:18 R.Zeus 閱讀(334) 評論(0)  編輯  收藏 所屬分類: ANTLR

    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 亚洲av综合av一区| 亚洲中文字幕不卡无码| 亚洲欧洲日产国码二区首页| 国产在线观看无码免费视频| 精品国产亚洲男女在线线电影 | 久久久久久久免费视频| 永久在线观看免费视频| 亚洲愉拍99热成人精品热久久| 亚洲精品白色在线发布| 免费亚洲视频在线观看| 最近中文字幕电影大全免费版| 亚洲国语精品自产拍在线观看 | 免费国产作爱视频网站| 亚洲国产美女视频| 少妇高潮太爽了在线观看免费| 国产精品久久亚洲不卡动漫| 国产性生大片免费观看性| 中文国产成人精品久久亚洲精品AⅤ无码精品 | 97视频热人人精品免费| 亚洲日韩精品无码专区加勒比☆ | 爽爽爽爽爽爽爽成人免费观看| 亚洲熟女一区二区三区| 99视频在线精品免费| 亚洲片国产一区一级在线观看 | 亚洲熟妇无码AV| 波多野结衣一区二区免费视频| 少妇亚洲免费精品| 国产精品免费_区二区三区观看| 亚洲国产成人久久综合一| 91久久精品国产免费直播| 亚洲一区二区三区丝袜| 亚洲人成人网站在线观看| 久久久久久久岛国免费播放| 亚洲欧洲日产国码无码网站| 久久久久久AV无码免费网站下载| 亚洲av片不卡无码久久| 亚洲 自拍 另类小说综合图区| 综合偷自拍亚洲乱中文字幕| 毛片免费在线观看网址| 特级毛片aaaa免费观看| 亚洲视频免费观看|