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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? lex-docs.txt

?? 句法分析器。一般用文法(grammar)來刻畫.常見的是短語結(jié)構(gòu)文法(chomsky hierarchy),其中最常用的是上下文無關(guān)文法(CFG)。
?? TXT
?? 第 1 頁 / 共 4 頁
字號:
http://www.cs.ucsb.edu/~cs160/machines/lex-docs.txt



                     Lex - A Lexical Analyzer Generator


                          M. E. Lesk and E. Schmidt



                                  ABSTRACT


       Lex helps write programs whose control flow is  directed  by
  instances of regular expressions in the input stream.  It is well
  suited for editor-script type transformations and for  segmenting
  input in preparation for a parsing routine.

       Lex source is a table of regular expressions and correspond-
  ing  program  fragments.   The  table  is translated to a program
  which reads an input stream, copying it to an output  stream  and
  partitioning the input into strings which match the given expres-
  sions.  As each such string is recognized the corresponding  pro-
  gram fragment is executed.  The recognition of the expressions is
  performed by a deterministic finite automaton generated  by  Lex.
  The  program  fragments  written  by the user are executed in the
  order in which the corresponding regular expressions occur in the
  input stream.

       The lexical analysis programs written with Lex accept  ambi-
  guous  specifications  and  choose  the longest match possible at
  each input point.  If necessary, substantial  lookahead  is  per-
  formed  on  the  input, but the input stream will be backed up to
  the end of the current partition, so that the  user  has  general
  freedom to manipulate it.

       Lex can generate analyzers in either C or Ratfor, a language
  which can be translated automatically to portable Fortran.  It is
  available on the PDP-11 UNIX, Honeywell GCOS, and IBM OS systems.
  This manual, however, will only discuss generating analyzers in C
  on the UNIX system, which is the only supported form of Lex under
  UNIX  Version  7.   Lex  is designed to simplify interfacing with
  Yacc, for those with access to this compiler-compiler system.



1.  Introduction.

     Lex is a program generator designed for lexical processing of
character input streams.  It accepts a high-level, problem
oriented specification for character string matching, and produces
a program in a general purpose language which recognizes regular
expressions.  The regular expressions are specified by the user in
the source specifications given to Lex.  The Lex written code
recognizes these expressions in an input stream and partitions the
input stream into strings matching the expressions.  At the
boundaries between strings program sections provided by the user
are executed.  The Lex source file associates the regular
expressions and the program fragments.  As each expression appears
in the input to the program written by Lex, the corresponding
fragment is executed.

     The user supplies the additional code beyond expression
matching needed to complete his tasks, possibly including code
written by other generators.  The program that recognizes the
expressions is generated in the general purpose programming
language employed for the user's program fragments.  Thus, a high
level expression language is provided to write the string
expressions to be matched while the user's freedom to write
actions is unimpaired.  This avoids forcing the user who wishes to
use a string manipulation language for input analysis to write
processing programs in the same and often inappropriate string
handling language.

     Lex is not a complete language, but rather a generator
representing a new language feature which can be added to
different programming languages, called ``host languages.'' Just
as general purpose languages can produce code to run on different
computer hardware, Lex can write code in different host languages.
The host language is used for the output code generated by Lex and
also for the program fragments added by the user.  Compatible
run-time libraries for the different host languages are also
provided.  This makes Lex adaptable to different environments and
different users.  Each application may be directed to the
combination of hardware and host language appropriate to the task,
the user's background, and the properties of local implementa-
tions.  At present, the only supported host language is C,
although Fortran (in the form of Ratfor [2] has been available in
the past.  Lex itself exists on UNIX, GCOS, and OS/370; but the
code generated by Lex may be taken anywhere the appropriate
compilers exist.

     Lex turns the user's expressions and actions (called source
in this memo) into the host general-purpose language; the
generated program is named yylex.  The yylex program will
recognize expressions in a stream (called input in this memo) and
perform the specified actions for each expression as it is
detected.  See Figure 1.
                                  +-------+
                        Source -> |  Lex  |  -> yylex
                                  +-------+

                                  +-------+
                        Input ->  | yylex | -> Output
                                  +-------+

                             An overview of Lex
                                  Figure 1

     For a trivial example, consider a program to delete from the
input all blanks or tabs at the ends of lines.
                                 %%
                                 [ \t]+$   ;
is all that is required.  The program contains a %% delimiter to
mark the beginning of the rules, and one rule.  This rule contains
a regular expression which matches one or more instances of the
characters blank or tab (written \t for visibility, in accordance
with the C language convention) just prior to the end of a line.
The brackets indicate the character class made of blank and tab;
the + indicates ``one or more ...''; and the $ indicates ``end
of line,'' as in QED.  No action is specified, so the program
generated by Lex (yylex) will ignore these characters.  Everything
else will be copied.  To change any remaining string of blanks or
tabs to a single blank, add another rule:
                           %%
                           [ \t]+$   ;
                           [ \t]+    printf(" ");
The finite automaton generated for this source will scan for both
rules at once, observing at the termination of the string of
blanks or tabs whether or not there is a newline character, and
executing the desired rule action.  The first rule matches all
strings of blanks or tabs at the end of lines, and the second rule
all remaining strings of blanks or tabs.

     Lex can be used alone for simple transformations, or for
analysis and statistics gathering on a lexical level.  Lex can
also be used with a parser generator to perform the lexical
analysis phase; it is particularly easy to interface Lex and Yacc
[3].  Lex programs recognize only regular expressions; Yacc writes
parsers that accept a large class of context free grammars, but
require a lower level analyzer to recognize input tokens.  Thus, a
combination of Lex and Yacc is often appropriate.  When used as
a preprocessor for a later parser generator, Lex is used to
partition the input stream, and the parser generator assigns
structure to the resulting pieces.  The flow of control in such
a case (which might be the first half of a compiler, for exam-
ple) is shown in Figure 2.  Additional programs, written by other
generators or by hand, can be added easily to programs written by
Lex.
                        lexical        grammar
                         rules          rules
                           |              |
                           v              v
                      +---------+    +---------+
                      |   Lex   |    |  Yacc   |
                      +---------+    +---------+
                           |              |
                           v              v
                      +---------+    +---------+
             Input -> |  yylex  | -> | yyparse | -> Parsed input
                      +---------+    +---------+


                            Lex with Yacc
                               Figure 2
Yacc users will realize that the name yylex is what Yacc expects
its lexical analyzer to be named, so that the use of this name by
Lex simplifies interfacing.

     Lex generates a deterministic finite automaton from the
regular expressions in the source [4].  The automaton is
interpreted, rather than compiled, in order to save space.  The
result is still a fast analyzer.  In particular, the time taken by
a Lex program to recognize and partition an input stream is
proportional to the length of the input.  The number of Lex rules
or the complexity of the rules is not important in determining
speed, unless rules which include forward context require a
significant amount of rescanning.  What does increase with the
number and complexity of rules is the size of the finite
automaton, and therefore the size of the program generated by Lex.

     In the program written by Lex, the user's fragments
(representing the actions to be performed as each regular
expression is found) are gathered as cases of a switch.  The
automaton interpreter directs the control flow.  Opportunity is
provided for the user to insert either declarations or addi-
tional statements in the routine containing the actions, or to add
subroutines outside this action routine.

     Lex is not limited to source which can be interpreted on the
basis of one character lookahead.  For example, if there are two
rules, one looking for ab and another for abcdefg, and the input
stream is abcdefh, Lex will recognize ab and leave the input
pointer just before cd. . .  Such backup is more costly than the
processing of simpler languages.

2.  Lex Source.

     The general format of Lex source is:
                             {definitions}
                             %%
                             {rules}
                             %%
                             {user subroutines}
where the definitions and the user subroutines are often omitted.
The second %% is optional, but the first is required to mark the
beginning of the rules.  The absolute minimum Lex program is thus
                                     %%
(no definitions, no rules) which translates into a program which
copies the input to the output unchanged.

     In the outline of Lex programs shown above, the rules
represent the user's control decisions; they are a table, in which
the left column contains regular expressions (see section 3) and
the right column contains actions, program fragments to be
executed when the expressions are recognized.  Thus an individual
rule might appear
                   integer   printf("found keyword INT");
to look for the string integer in the input stream and print the
message ``found keyword INT'' whenever it appears.  In this
example the host procedural language is C and the C library
function printf is used to print the string.  The end of the
expression is indicated by the first blank or tab character.  If
the action is merely a single C expression, it can just be given
on the right side of the line; if it is compound, or takes more
than a line, it should be enclosed in braces.  As a slightly more
useful example, suppose it is desired to change a number of words
from British to American spelling.  Lex rules such as
                      colour      printf("color");
                      mechanise   printf("mechanize");
                      petrol      printf("gas");
would be a start.  These rules are not quite enough, since the
word petroleum would become gaseum; a way of dealing with this
will be described later.

3.  Lex Regular Expressions.

     The definitions of regular expressions are very similar to
those in QED [5].  A regular expression specifies a set of strings
to be matched.  It contains text characters (which match the
corresponding characters in the strings being compared) and
operator characters (which specify repetitions, choices, and other
features).  The letters of the alphabet and the digits are always
text characters; thus the regular expression
                                 integer
matches the string integer wherever it appears and the expression
                                    a57D
looks for the string a57D.

     Operators.  The operator characters are
                   " \ [ ] ^ - ? . * + | ( ) $ / { } % < >
and if they are to be used as text characters, an escape should be
used.  The quotation mark operator (") indicates that whatever is
contained between a pair of quotes is to be taken as text
characters.  Thus
                                   xyz"++"
matches the string xyz++ when it appears.  Note that a part of a
string may be quoted.  It is harmless but unnecessary to quote an
ordinary text character; the expression
                                   "xyz++"
is the same as the one above.  Thus by quoting every
non-alphanumeric character being used as a text character, the
user can avoid remembering the list above of current operator
characters, and is safe should further extensions to Lex lengthen
the list.

     An operator character may also be turned into a text
character by preceding it with \ as in
                                   xyz\+\+
which is another, less readable, equivalent of the above
expressions.  Another use of the quoting mechanism is to get a
blank into an expression; normally, as explained above, blanks or
tabs end a rule.  Any blank character not contained within [] (see
below) must be quoted.  Several normal C escapes with \ are
recognized: \n is newline, \t is tab, and \b is backspace.  To
enter \ itself, use \\.  Since newline is illegal in an
expression, \n must be used; it is not required to escape tab and
backspace.  Every character but blank, tab, newline and the list
above is always a text character.

     Character classes.  Classes of characters can be specified
using the operator pair [].  The construction [abc] matches a
single character, which may be a, b, or c.  Within square
brackets, most operator meanings are ignored.  Only three
characters are special: these are \ - and ^.  The - character
indicates ranges.  For example,
                                 [a-z0-9<>_]
indicates the character class containing all the lower case
letters, the digits, the angle brackets, and underline.  Ranges
may be given in either order.  Using - between any pair of

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产欧美一区二区三区鸳鸯浴| av中文字幕一区| 欧美日韩成人综合在线一区二区| 亚洲综合999| 欧美午夜免费电影| 五月天激情综合网| 精品久久久久av影院| 国产精品一线二线三线精华| 国产精品欧美久久久久无广告 | 欧美一区永久视频免费观看| 美国欧美日韩国产在线播放| 久久久另类综合| 99久久亚洲一区二区三区青草| 亚洲人妖av一区二区| 色吊一区二区三区| 日本中文一区二区三区| 久久中文字幕电影| 成人夜色视频网站在线观看| 亚洲蜜桃精久久久久久久| 91精品国产免费| 国产福利91精品| 亚洲一区中文在线| 日韩美女一区二区三区| 成人激情免费电影网址| 亚洲国产一区二区在线播放| 欧美大片在线观看一区二区| 成人国产精品免费观看动漫 | 亚洲亚洲人成综合网络| 日韩欧美色电影| caoporn国产精品| 美腿丝袜亚洲色图| 亚洲乱码国产乱码精品精的特点 | 一区二区三区日韩精品| 日韩欧美的一区| 一本色道综合亚洲| 国产一区美女在线| 亚洲电影视频在线| 国产女主播一区| 欧美一级片在线| 91麻豆免费观看| 韩国av一区二区三区四区| 一区二区三区成人| 国产亚洲欧洲一区高清在线观看| 欧美午夜精品久久久久久孕妇| 国产精品18久久久久久久久久久久 | 国产亚洲1区2区3区| 欧美图片一区二区三区| 成人午夜精品在线| 麻豆91在线看| 亚洲电影激情视频网站| 日韩毛片视频在线看| 欧美精品一区二区三区四区| 欧美日韩视频一区二区| 99在线精品视频| 国产成人精品1024| 国内精品伊人久久久久av影院| 亚洲国产成人av| 亚洲日韩欧美一区二区在线| 久久婷婷成人综合色| 911精品国产一区二区在线| 色狠狠色噜噜噜综合网| 成人av资源网站| 国产成人综合视频| 国产伦理精品不卡| 麻豆成人91精品二区三区| 日韩电影免费在线| 亚洲成人www| 亚洲一区二区黄色| 一区二区在线观看免费视频播放| 国产精品麻豆一区二区| 久久精品一区四区| 久久精品欧美日韩精品| 国产午夜精品美女毛片视频| 精品理论电影在线| 欧美一级片免费看| 精品少妇一区二区三区免费观看| 欧美久久一二三四区| 欧美人伦禁忌dvd放荡欲情| 欧美亚洲国产一卡| 欧美色偷偷大香| 欧美系列亚洲系列| 在线不卡中文字幕| 日韩一级免费观看| 精品国产乱码久久久久久1区2区| 日韩免费高清av| 精品久久久三级丝袜| 久久久久青草大香线综合精品| 久久新电视剧免费观看| 久久久精品欧美丰满| 国产精品超碰97尤物18| 亚洲精品乱码久久久久久日本蜜臀| 亚洲品质自拍视频| 亚洲一区在线免费观看| 天堂蜜桃一区二区三区| 免费视频一区二区| 国产99久久久久| 色综合一个色综合| 欧美日韩国产免费一区二区 | 国产美女娇喘av呻吟久久| 国产成人午夜片在线观看高清观看| 成人综合在线观看| 91色.com| 欧美一区二区三区在线视频| 精品国产一区二区在线观看| 国产亚洲欧洲一区高清在线观看| 亚洲同性同志一二三专区| 亚洲成a人在线观看| 九一久久久久久| av爱爱亚洲一区| 欧美日韩一级黄| 国产欧美一区视频| 亚洲精品免费在线观看| 麻豆精品久久久| av电影一区二区| 91精品国产综合久久久蜜臀粉嫩| 久久日韩粉嫩一区二区三区| 亚洲欧美日韩国产手机在线 | 久久不见久久见免费视频7| 成人av网在线| 5858s免费视频成人| 欧美国产激情二区三区 | 日韩午夜小视频| 欧美高清一级片在线观看| 亚洲不卡av一区二区三区| 国产一区二区三区精品视频| 欧美在线你懂的| 国产亚洲综合性久久久影院| 午夜精品久久久久久久久久| 高清beeg欧美| 日韩欧美一级精品久久| 亚洲天堂网中文字| 国内精品伊人久久久久av一坑| 欧美三级在线看| 中文字幕精品一区二区三区精品| 天天综合网 天天综合色| 成人激情免费视频| 亚洲精品在线网站| 亚洲超碰精品一区二区| 97精品久久久午夜一区二区三区 | 国产91精品入口| 日韩区在线观看| 亚洲国产视频直播| 成人av在线网站| 久久九九久精品国产免费直播| 三级不卡在线观看| 日本精品一级二级| 国产精品乱人伦中文| 韩国av一区二区三区在线观看| 91.com视频| 亚洲综合区在线| 91女神在线视频| 亚洲欧美自拍偷拍色图| 国产成人免费xxxxxxxx| 精品毛片乱码1区2区3区| 五月婷婷激情综合网| 91行情网站电视在线观看高清版| 中文字幕精品综合| 国产电影精品久久禁18| 久久女同精品一区二区| 韩国精品主播一区二区在线观看| 91精品国产色综合久久不卡电影 | 正在播放亚洲一区| 三级久久三级久久| 在线播放日韩导航| 午夜视频在线观看一区二区| 欧美综合色免费| 樱桃国产成人精品视频| 一本色道久久综合亚洲aⅴ蜜桃| 成人免费在线观看入口| 99re这里都是精品| 亚洲日本免费电影| 色综合久久中文字幕| 亚洲精品国久久99热| 色婷婷av一区二区| 亚洲一区二区四区蜜桃| 欧洲激情一区二区| 视频一区二区三区在线| 日韩欧美美女一区二区三区| 韩国女主播成人在线| 国产校园另类小说区| 成人app软件下载大全免费| 中文字幕日本不卡| 欧美无乱码久久久免费午夜一区 | 久久久久综合网| 成人免费av资源| 国产精品久久久久久久久免费樱桃| 成人综合婷婷国产精品久久蜜臀 | 欧美一区二区三区免费大片| 麻豆高清免费国产一区| 欧美经典一区二区三区| aaa亚洲精品一二三区| 亚洲主播在线播放| 91精品欧美一区二区三区综合在 | 亚洲二区在线视频| 欧美成人乱码一区二区三区| 福利一区二区在线| 一区二区久久久| 日韩欧美色综合网站| 不卡免费追剧大全电视剧网站| 一区二区三区在线观看国产|