亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? lemon.html

?? 嵌入式數據庫
?? HTML
?? 第 1 頁 / 共 3 頁
字號:
<html><head><title>The Lemon Parser Generator</title></head><body bgcolor=white><h1 align=center>The Lemon Parser Generator</h1><p>Lemon is an LALR(1) parser generator for C or C++.  It does the same job as ``bison'' and ``yacc''.But lemon is not another bison or yacc clone.  Ituses a different grammar syntax which is designed toreduce the number of coding errors.  Lemon also uses a moresophisticated parsing engine that is faster than yacc andbison and which is both reentrant and thread-safe.Furthermore, Lemon implements features that can be usedto eliminate resource leaks, making is suitable for usein long-running programs such as graphical user interfacesor embedded controllers.</p><p>This document is an introduction to the Lemonparser generator.</p><h2>Theory of Operation</h2><p>The main goal of Lemon is to translate a context free grammar (CFG)for a particular language into C code that implements a parser forthat language.The program has two inputs:<ul><li>The grammar specification.<li>A parser template file.</ul>Typically, only the grammar specification is supplied by the programmer.Lemon comes with a default parser template which works fine for mostapplications.  But the user is free to substitute a different parsertemplate if desired.</p><p>Depending on command-line options, Lemon will generate betweenone and three files of outputs.<ul><li>C code to implement the parser.<li>A header file defining an integer ID for each terminal symbol.<li>An information file that describes the states of the generated parser    automaton.</ul>By default, all three of these output files are generated.The header file is suppressed if the ``-m'' command-line option isused and the report file is omitted when ``-q'' is selected.</p><p>The grammar specification file uses a ``.y'' suffix, by convention.In the examples used in this document, we'll assume the name of thegrammar file is ``gram.y''.  A typical use of Lemon would be thefollowing command:<pre>   lemon gram.y</pre>This command will generate three output files named ``gram.c'',``gram.h'' and ``gram.out''.The first is C code to implement the parser.  The secondis the header file that defines numerical values for allterminal symbols, and the last is the report that explainsthe states used by the parser automaton.</p><h3>Command Line Options</h3><p>The behavior of Lemon can be modified using command-line options.You can obtain a list of the available command-line options togetherwith a brief explanation of what each does by typing<pre>   lemon -?</pre>As of this writing, the following command-line options are supported:<ul><li><tt>-b</tt><li><tt>-c</tt><li><tt>-g</tt><li><tt>-m</tt><li><tt>-q</tt><li><tt>-s</tt><li><tt>-x</tt></ul>The ``-b'' option reduces the amount of text in the report file byprinting only the basis of each parser state, rather than the fullconfiguration.The ``-c'' option suppresses action table compression.  Using -cwill make the parser a little larger and slower but it will detectsyntax errors sooner.The ``-g'' option causes no output files to be generated at all.Instead, the input grammar file is printed on standard output butwith all comments, actions and other extraneous text deleted.  Thisis a useful way to get a quick summary of a grammar.The ``-m'' option causes the output C source file to be compatiblewith the ``makeheaders'' program.Makeheaders is a program that automatically generates header filesfrom C source code.  When the ``-m'' option is used, the headerfile is not output since the makeheaders program will take careof generated all header files automatically.The ``-q'' option suppresses the report file.Using ``-s'' causes a brief summary of parser statistics to beprinted.  Like this:<pre>   Parser statistics: 74 terminals, 70 nonterminals, 179 rules                      340 states, 2026 parser table entries, 0 conflicts</pre>Finally, the ``-x'' option causes Lemon to print its version numberand then stops without attempting to read the grammar or generate a parser.</p><h3>The Parser Interface</h3><p>Lemon doesn't generate a complete, working program.  It only generatesa few subroutines that implement a parser.  This section describesthe interface to those subroutines.  It is up to the programmer tocall these subroutines in an appropriate way in order to produce acomplete system.</p><p>Before a program begins using a Lemon-generated parser, the programmust first create the parser.A new parser is created as follows:<pre>   void *pParser = ParseAlloc( malloc );</pre>The ParseAlloc() routine allocates and initializes a new parser andreturns a pointer to it.The actual data structure used to represent a parser is opaque --its internal structure is not visible or usable by the calling routine.For this reason, the ParseAlloc() routine returns a pointer to voidrather than a pointer to some particular structure.The sole argument to the ParseAlloc() routine is a pointer to thesubroutine used to allocate memory.  Typically this means ``malloc()''.</p><p>After a program is finished using a parser, it can reclaim allmemory allocated by that parser by calling<pre>   ParseFree(pParser, free);</pre>The first argument is the same pointer returned by ParseAlloc().  Thesecond argument is a pointer to the function used to release bulkmemory back to the system.</p><p>After a parser has been allocated using ParseAlloc(), the programmermust supply the parser with a sequence of tokens (terminal symbols) tobe parsed.  This is accomplished by calling the following functiononce for each token:<pre>   Parse(pParser, hTokenID, sTokenData, pArg);</pre>The first argument to the Parse() routine is the pointer returned byParseAlloc().The second argument is a small positive integer that tells the parse thetype of the next token in the data stream.There is one token type for each terminal symbol in the grammar.The gram.h file generated by Lemon contains #define statements thatmap symbolic terminal symbol names into appropriate integer values.(A value of 0 for the second argument is a special flag to theparser to indicate that the end of input has been reached.)The third argument is the value of the given token.  By default,the type of the third argument is integer, but the grammar willusually redefine this type to be some kind of structure.Typically the second argument will be a broad category of tokenssuch as ``identifier'' or ``number'' and the third argument willbe the name of the identifier or the value of the number.</p><p>The Parse() function may have either three or four arguments,depending on the grammar.  If the grammar specification file requestit, the Parse() function will have a fourth parameter that can beof any type chosen by the programmer.  The parser doesn't do anythingwith this argument except to pass it through to action routines.This is a convenient mechanism for passing state information downto the action routines without having to use global variables.</p><p>A typical use of a Lemon parser might look something like thefollowing:<pre>   01 ParseTree *ParseFile(const char *zFilename){   02    Tokenizer *pTokenizer;   03    void *pParser;   04    Token sToken;   05    int hTokenId;   06    ParserState sState;   07   08    pTokenizer = TokenizerCreate(zFilename);   09    pParser = ParseAlloc( malloc );   10    InitParserState(&sState);   11    while( GetNextToken(pTokenizer, &hTokenId, &sToken) ){   12       Parse(pParser, hTokenId, sToken, &sState);   13    }   14    Parse(pParser, 0, sToken, &sState);   15    ParseFree(pParser, free );   16    TokenizerFree(pTokenizer);   17    return sState.treeRoot;   18 }</pre>This example shows a user-written routine that parses a file oftext and returns a pointer to the parse tree.(We've omitted all error-handling from this example to keep itsimple.)We assume the existence of some kind of tokenizer which is createdusing TokenizerCreate() on line 8 and deleted by TokenizerFree()on line 16.  The GetNextToken() function on line 11 retrieves thenext token from the input file and puts its type in the integer variable hTokenId.  The sToken variable is assumed to besome kind of structure that contains details about each token,such as its complete text, what line it occurs on, etc. </p><p>This example also assumes the existence of structure of typeParserState that holds state information about a particular parse.An instance of such a structure is created on line 6 and initializedon line 10.  A pointer to this structure is passed into the Parse()routine as the optional 4th argument.The action routine specified by the grammar for the parser can usethe ParserState structure to hold whatever information is useful andappropriate.  In the example, we note that the treeRoot field ofthe ParserState structure is left pointing to the root of the parsetree.</p><p>The core of this example as it relates to Lemon is as follows:<pre>   ParseFile(){      pParser = ParseAlloc( malloc );      while( GetNextToken(pTokenizer,&hTokenId, &sToken) ){         Parse(pParser, hTokenId, sToken);      }      Parse(pParser, 0, sToken);      ParseFree(pParser, free );   }</pre>Basically, what a program has to do to use a Lemon-generated parseris first create the parser, then send it lots of tokens obtained bytokenizing an input source.  When the end of input is reached, theParse() routine should be called one last time with a token typeof 0.  This step is necessary to inform the parser that the end ofinput has been reached.  Finally, we reclaim memory used by theparser by calling ParseFree().</p><p>There is one other interface routine that should be mentionedbefore we move on.The ParseTrace() function can be used to generate debugging outputfrom the parser.  A prototype for this routine is as follows:<pre>   ParseTrace(FILE *stream, char *zPrefix);</pre>After this routine is called, a short (one-line) message is writtento the designated output stream every time the parser changes statesor calls an action routine.  Each such message is prefaced usingthe text given by zPrefix.  This debugging output can be turned offby calling ParseTrace() again with a first argument of NULL (0).</p><h3>Differences With YACC and BISON</h3><p>Programmers who have previously used the yacc or bison parsergenerator will notice several important differences between yacc and/orbison and Lemon.<ul><li>In yacc and bison, the parser calls the tokenizer.  In Lemon,    the tokenizer calls the parser.<li>Lemon uses no global variables.  Yacc and bison use global variables    to pass information between the tokenizer and parser.<li>Lemon allows multiple parsers to be running simultaneously.  Yacc    and bison do not.</ul>These differences may cause some initial confusion for programmerswith prior yacc and bison experience.But after years of experience using Lemon, I firmlybelieve that the Lemon way of doing things is better.</p><h2>Input File Syntax</h2><p>The main purpose of the grammar specification file for Lemon isto define the grammar for the parser.  But the input file alsospecifies additional information Lemon requires to do its job.Most of the work in using Lemon is in writing an appropriategrammar file.</p><p>The grammar file for lemon is, for the most part, free format.It does not have sections or divisions like yacc or bison.  Anydeclaration can occur at any point in the file.Lemon ignores whitespace (except where it is needed to separatetokens) and it honors the same commenting conventions as C and C++.</p><h3>Terminals and Nonterminals</h3><p>A terminal symbol (token) is any string of alphanumericand underscore charactersthat begins with an upper case letter.A terminal can contain lower class letters after the first character,but the usual convention is to make terminals all upper case.A nonterminal, on the other hand, is any string of alphanumericand underscore characters than begins with a lower case letter.Again, the usual convention is to make nonterminals use all lowercase letters.</p><p>In Lemon, terminal and nonterminal symbols do not need to be declared or identified in a separate section of the grammar file.Lemon is able to generate a list of all terminals and nonterminalsby examining the grammar rules, and it can always distinguish aterminal from a nonterminal by checking the case of the firstcharacter of the name.</p>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人h动漫精品一区二区| 青青草原综合久久大伊人精品 | 91精品国模一区二区三区| 国产午夜三级一区二区三| 亚洲在线成人精品| 高清视频一区二区| 91麻豆精品91久久久久久清纯| 国产精品免费久久| 精品一区二区免费视频| 欧美日韩午夜在线| 亚洲天堂精品在线观看| 国产黄色91视频| 91精选在线观看| 亚洲国产欧美日韩另类综合 | 日韩av电影免费观看高清完整版 | 国产精品免费网站在线观看| 老司机免费视频一区二区| 欧美亚洲尤物久久| 18成人在线观看| 成人丝袜18视频在线观看| 欧美精品一区二区三区在线播放 | 一区二区三区中文字幕精品精品| 国产福利不卡视频| 欧美大片一区二区三区| 性做久久久久久免费观看欧美| www.爱久久.com| 国产喷白浆一区二区三区| 久久99精品国产麻豆婷婷| 欧美一级国产精品| 三级不卡在线观看| 欧美日韩视频在线一区二区| 亚洲一区二区三区四区在线 | 国产suv一区二区三区88区| 久久国产三级精品| 欧美性videosxxxxx| 亚洲国产精品v| 欧美三区在线观看| 懂色av一区二区三区蜜臀| 日韩毛片高清在线播放| 日本韩国欧美在线| 国产精品国产三级国产aⅴ中文| 风流少妇一区二区| 亚洲精品国产一区二区精华液| 欧美日韩在线精品一区二区三区激情 | 中文字幕 久热精品 视频在线 | 亚洲三级免费电影| 日本伦理一区二区| 亚洲另类色综合网站| 99久久伊人久久99| 中文字幕中文字幕一区二区| 蜜臀av亚洲一区中文字幕| 成人97人人超碰人人99| 中文字幕人成不卡一区| 91一区一区三区| 99久久精品免费看| 亚洲成人综合视频| 久久麻豆一区二区| 在线观看一区二区视频| 国产在线播放一区二区三区| 国产精品久久久99| 欧美电影免费观看高清完整版| 一本久久精品一区二区| 欧美一区二区视频免费观看| 美国十次了思思久久精品导航| 91精品国产品国语在线不卡| 久久草av在线| 日本一区二区三区四区在线视频 | 26uuu国产电影一区二区| 国产尤物一区二区在线| 国产精品不卡一区| 欧美性受极品xxxx喷水| 麻豆精品新av中文字幕| 国产欧美精品区一区二区三区| 成人动漫av在线| 亚洲午夜精品一区二区三区他趣| 欧美妇女性影城| 国产在线精品一区二区 | 91精品国产手机| 国产一区二区三区不卡在线观看| 国产精品久久久久精k8| 欧美日韩精品欧美日韩精品一| 久久99精品国产.久久久久久| 国产精品日韩成人| 精品视频在线免费看| 精品一区二区av| ...av二区三区久久精品| 欧美妇女性影城| 成人网在线免费视频| 色综合久久中文综合久久牛| 国产成人在线色| 欧美在线一二三四区| 91精选在线观看| 欧美一区二区视频观看视频| 日韩一二在线观看| 欧美一级xxx| 日韩欧美一级二级三级久久久| 精品毛片乱码1区2区3区| 欧美成人精品福利| 日韩中文欧美在线| 久久99深爱久久99精品| 欧美激情资源网| 欧美性淫爽ww久久久久无| 久久99精品国产.久久久久久| 自拍偷拍亚洲欧美日韩| 日韩一区二区免费在线电影| 成人午夜激情影院| 免费在线成人网| 综合久久国产九一剧情麻豆| 欧美电影免费观看高清完整版在线观看 | 99久久精品国产精品久久| 中文字幕日韩av资源站| 日韩精品资源二区在线| 色悠悠久久综合| 国产一区二区三区观看| 天天影视网天天综合色在线播放| 国产三级精品视频| 日韩午夜在线观看视频| 欧美三级日韩三级| www.欧美日韩| 国产东北露脸精品视频| 麻豆精品视频在线观看免费 | 国产欧美日韩中文久久| 91麻豆精品国产| 欧美在线视频日韩| 97精品久久久久中文字幕 | 午夜成人在线视频| 亚洲日本韩国一区| 中文字幕av资源一区| 久久久www成人免费毛片麻豆| 91精品国产一区二区三区| 欧美三级在线视频| 色天使色偷偷av一区二区| 白白色亚洲国产精品| 成人性生交大片免费看视频在线 | 色综合色综合色综合 | 欧美aa在线视频| 欧美一区二区三区喷汁尤物| 亚洲欧洲日产国产综合网| 久久99蜜桃精品| 欧美精品一区二区久久久| 青青草伊人久久| 欧美一级理论性理论a| 亚瑟在线精品视频| 717成人午夜免费福利电影| 一区二区三区资源| 有码一区二区三区| 一区二区免费在线| 亚洲欧美另类综合偷拍| 国产精品欧美极品| 中文字幕欧美激情一区| 国产偷国产偷精品高清尤物| 久久久久88色偷偷免费| 2欧美一区二区三区在线观看视频| 日韩精品一区二区三区蜜臀 | 国内精品国产成人国产三级粉色| 日韩av不卡一区二区| 日av在线不卡| 日本一不卡视频| 日韩高清国产一区在线| 首页亚洲欧美制服丝腿| 全国精品久久少妇| 免费高清在线一区| 久久av老司机精品网站导航| 国产真实乱子伦精品视频| 国内精品自线一区二区三区视频| 狠狠v欧美v日韩v亚洲ⅴ| 国产美女精品在线| 盗摄精品av一区二区三区| k8久久久一区二区三区| 99久久综合色| 欧亚洲嫩模精品一区三区| 欧美日韩在线不卡| 91精品国产黑色紧身裤美女| 精品久久久久久久久久久久久久久久久 | 欧美视频一二三区| 欧美男生操女生| 日韩欧美专区在线| 国产欧美日本一区二区三区| 国产精品久久免费看| 亚洲国产欧美在线人成| 蜜桃av一区二区三区| 国产精品1区二区.| 99精品一区二区三区| 欧美日韩国产一级| 欧美性大战xxxxx久久久| 国产成人啪免费观看软件| 偷拍亚洲欧洲综合| 奇米精品一区二区三区四区| 亚洲国产高清不卡| 日韩免费电影一区| 在线观看亚洲精品视频| 不卡一区在线观看| 日韩福利电影在线观看| 亚洲综合视频在线| 国产精品系列在线| 精品国产成人系列| 欧美精品123区| 欧美人成免费网站| 欧美巨大另类极品videosbest| 懂色av一区二区夜夜嗨|