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

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

?? cocol

?? 自己寫的關于編譯原理的實驗報告的源代碼
??
?? 第 1 頁 / 共 2 頁
字號:
The compiler description language Cocol/R
=========================================

 (This is a modified version of parts of Professor Moessenboeck's 1990 paper
  to allow for the fact that this implementation is for C/C++.  The full
  version of the paper should be consulted by serious users.)

A compiler description can be viewed as a module consisting of imports,
declarations and grammar rules that describe the lexical and syntactical
structure of a language as well as its translation into a target language.
The vocabulary of Cocol/R uses identifiers, strings and numbers in the usual
way:

   ident  = letter { letter | digit } .
   string = '"' { anyButQuote } '"' | "'" { anyButApostrophe } "'" .
   number = digit { digit } .

Upper case letters are distinct from lower case letters.  Strings must not
cross line borders.  Coco/R keywords are

    ANY  CASE  CHARACTERS  CHR  COMMENTS  COMPILER  CONTEXT  END  EOF FROM
    IGNORE  NAMES  NESTED  PRAGMAS  PRODUCTIONS  SYNC  TO  TOKENS  WEAK

(NAMES is an extension over the original Oberon implementation.)

The following metasymbols are used to form EBNF expressions:

      (    )       for grouping
      {    }       for iterations
      [    ]       for options
      <    >       for attributes
      (.  .)       for semantic parts
      = . | + -    as explained below

Comments are enclosed in "/*" and "*/" brackets, and may be nested.  The
semantic parts may contain declarations or statements in a general purpose
programming language (in this case, C or C++).

The Oberon, Modula-2 and Pascal implementations use "(*" and "*)" for
comments; the C/C++ versions use C like comments because "(*" can cause
problems in semantic actions, for example: (. while (*s) do *s++ .)
where "(*" clearly is not intended to begin a comment.


Overall Structure
=================

A compiler description is made up of the following parts

   Cocol =   "COMPILER" GoalIdentifier
                 ArbitraryText 
                 ScannerSpecification 
                 ParserSpecification 
             "END" GoalIdentifier "." . 

The name after the keyword COMPILER is the grammar name and must match the
name after the keyword END.  The grammar name also denotes the topmost
non-terminal (the start symbol).

After the grammar name, arbitrary C/C++ text may follow; this is not checked
by Coco/R.  It usually contains C/C++ declarations of global objects
(constants, types, variables, or procedures) that are needed in the semantic
actions later on.

The remaining parts of the compiler description specify the lexical and
syntactical structure of the language to be processed.  Effectively two
grammars are specified - one for the lexical analyser or scanner, and the
other for the syntax analyser or parser.  The non-terminals (token classes)
recognized by the scanner are regarded as terminals by the parser.


Scanner Specification
=====================

A scanner has to read source text, skip meaningless characters, and recognize 
tokens that have to be passed to the parser.  Tokens may be classified as
literals or as token classes.  Literals (like "END" and "!=") may be
introduced directly into productions as strings, and do not need to be named.
Token classes (such as identifiers or numbers) must be named, and have
structures that are specified by regular expressions, defined in EBNF.

In Cocol, a scanner specification consists of six optional parts, that may, in
fact, be introduced in arbitrary order. 

   ScannerSpecification =  {  CharacterSets 
                             | Ignorable 
                             | Comments 
                             | Tokens 
                             | Pragmas 
                             | UserNames 
                            } . 

CHARACTERS
----------

The CharacterSets component allows for the declaration of names for character
sets like letters or digits, and defines the characters that may occur as
members of these sets.  These names then may be used in the other sections of
the scanner specification (but not, it should be noted, in the parser
specification).

   CharacterSets   =  "CHARACTERS" { NamedCharSet } . 
   NamedCharSet    =  SetIdent "=" CharacterSet "." . 
   CharacterSet    =  SimpleSet { ( "+" | "-" ) SimpleSet } . 
   SimpleSet       =    SetIdent | string | "ANY"
                      | SingleChar [ ".." SingleChar ] .
   SingleChar      =  "CHR" "(" number ")" . 
   SetIdent        =  identifier . 

Simple character sets are denoted by one of 

   SetIdent           a previously declared character set with that name 
   string             a set consisting of all characters in the string 
   CHR(i)             a set of one character with ordinal value i
   CHR(i) .. CHR(j)   a set consisting of all characters whose ordinal
                      values are in the range i ... j.
   ANY                the set of all characters acceptable to the
                      implementation

Simple sets may then be combined by the union (+) and difference operators
(-). 

The ability to specify a range like CHR(7) .. CHR(31) is an extension over
the original Oberon implementation.

   EXAMPLES:
      digit = "0123456789" .           The set of all digits
      hexdigit = digit + "ABCDEF" .    The set of all hexadecimal digits
      eol = CHR(13) .                  End-of-line character
      noDigit = ANY - digit .          Any character that is not a digit
      ctrlChars = CHR(1) .. CHR(31) .  The ascii control characters


COMMENTS AND IGNORABLE CHARACTERS
---------------------------------

Usually spaces within the source text of a program are irrelevant, and in
scanning for the start of a token, a Coco/R generated scanner will simply
ignore them.  Other separators like tabs, line ends, and form feeds may also
be declared irrelevant, and some applications may prefer to ignore the
distinction between upper and lower case input.

Comments are difficult to specify with the regular expressions used to denote
tokens - indeed, nested comments may not be specified at all in this way.
Since comments are usually discarded by a parsing process, and may typically
appear in arbitrary places in source code, it makes sense to have a special
construct to express their structure.

Ignorable aspects of the scanning process are defined in Cocol by 

   Comments  = "COMMENTS" "FROM" TokenExpr "TO" TokenExpr [ "NESTED" ] . 
   Ignorable = "IGNORE" ( "CASE" | CharacterSet ) . 

where the optional keyword NESTED should have an obvious meaning.  A practical
restriction is that comment brackets must not be longer than 2 characters.  It
is possible to declare several kinds of comments within a single grammar, for
example, for C++:

      COMMENTS FROM "/*" TO "*/" 
      COMMENTS FROM "//" TO eol 
      IGNORE CHR(9) .. CHR(13) 

The set of ignorable characters in this example is that which includes the
standard white space separators in ASCII files.  The null character CHR(0)
should not be included in any ignorable set.  It is used internally by Coco/R
to mark the end of the input file.


TOKENS
------

A very important part of the scanner specification declares the form of
terminal tokens: 

   Tokens       =  "TOKENS" { Token } . 
   Token        =  TokenSymbol [ "=" TokenExpr "." ] . 
   TokenExpr    =  TokenTerm { "|" TokenTerm } . 
   TokenTerm    =  TokenFactor { TokenFactor } [ "CONTEXT" "(" TokenExpr ")" ] . 
   TokenFactor  =  SetIdent | string 
                     | "(" TokenExpr ")" 
                     | "[" TokenExpr "]" 
                     | "{" TokenExpr "}" . 
   TokenSymbol  =  TokenIdent | string . 
   TokenIdent   =  identifier . 

Tokens may be declared in any order.  A token declaration defines a
TokenSymbol together with its structure. Usually the symbol on the left-hand
side of the declaration is an identifier, which is then used in other parts of
the grammar to denote the structure described on the right-hand side of the
declaration by a regular expression (expressed in EBNF).  This expression may
contain literals denoting themselves (for example "END"), or the names of
character sets (for example letter), denoting an arbitrary character from such
sets.  The restriction to regular expressions means that it may not contain
the names of any other tokens.

While token specification is usually straightforward, there are a number of
subtleties that may need emphasizing: 

 - There is one predeclared token EOF that can be used in productions where
   it is necessary to check explicitly that the end of the source has been
   reached.  When the Scanner detects that the end of the source has been
   reached further attempts to obtain a token return only this one.

 - Since spaces are deemed to be irrelevant when they come between tokens in
   the input for most languages, one should not attempt to declare literal
   tokens that have spaces within them.

 - The grammar for tokens allows for empty right-hand sides.  This may seem
   strange, especially as no scanner is generated if the right-hand side of a
   declaration is missing.  This facility is used if the user wishes to supply
   a hand-crafted scanner, rather than the one generated by Coco/R.  In this
   case, the symbol on the left-hand side of a token declaration may also
   simply be specified by a string, with no right-hand side.

 - Tokens specified without right-hand sides are numbered consecutively
   starting from 0, and the hand-crafted scanner has to return token codes
   according to this numbering scheme.

 - The CONTEXT phrase in a TokenTerm means that the term is only recognized
   when its right hand context in the input stream is the TokenExpr specified
   in brackets.

   EXAMPLES:
      ident   =   letter { letter | digit } .
      real    =   digit { digit } "." { digit }
                   [ "E" [ "+" | "-" ] digit { digit } ] .
      number  =   digit { digit }
                | digit { digit } CONTEXT ( ".." ) .
      and     =   "&".

The CONTEXT phrase in the above example allows a distinction between reals
(e.g. 1.23) and range constructs (e.g. 1..2) that could otherwise not be
scanned with a single character lookahead.


PRAGMAS
-------

A pragma, like a comment, is a token that may occur anywhere in the input
stream, but, unlike a comment, it cannot be ignored.  Pragmas are often used
to allow programmers to select compiler switches dynamically.  Since it
becomes impractical to modify the phrase structure grammar to handle this, a
special mechanism is provided for the recognition and treatment of pragmas.
In Cocol they are declared like tokens, but may have an associated semantic
action that is executed whenever they are recognized by the scanner.

   Pragmas     =  "PRAGMAS" { Pragma } . 
   Pragma      =  Token [ Action ] . 
   Action      =  "(." arbitraryText ".)" . 

   EXAMPLE:
     option = "$" { letter } .
         (. char str[50]; int i;
            S_GetString(S_Pos, S_Len, str);
            i = 0;
            while (i < S_Len) {
              switch (str[i]) {
              ...
              }
              i++;
            } .)


USER NAMES
----------

Coco/R, by default, generates symbolic names for token symbols, sometimes
having a rather stereotyped form.  The UserNames section may be used to prefer
user-defined names, or to help resolve name clashes (for example, between the
default names that would be chosen for "point" and ".").

   UserNames  = "NAMES" { UserName } . 
   UserName   = TokenIdent  "=" ( identifier | string ) "." . 

   EXAMPLES:
      NAMES 
        period   = "." . 
        ellipsis = "..." . 

For special purposes the symbol on the left-hand side may also be a string,
in which case no right-hand side may be specified; this is used if the user
wishes to supply a hand-crafted scanner.  Indeed, if the right-hand side
of a declaration is missing, no scanner is generated.

The ability to use names is an extension over the original Oberon
implementation.


Parser Specification
====================

The parser specification is the main part of the input to Coco/R.  It contains
the productions of an attributed grammar specifying the syntax of the language
to be recognized, as well as the action to be taken as each phrase or token is
recognized.

The form of the parser specification may itself be described in EBNF as
follows.  For the Modula-2 and Pascal versions we have:

   ParserSpecification =  "PRODUCTIONS" { Production } . 
   Production          =  NonTerminal [ FormalAttributes ] 
                            [ LocalDeclarations ]     (* Modula-2 and Pascal *)
                            "=" Expression "." . 
   FormalAttributes    =  "<"  arbitraryText ">" | "<."  arbitraryText ".>" .
   LocalDeclarations   =  "(." arbitraryText ".)" . 
   NonTerminal         =  identifier . 

For the C and C++ versions the LocalDeclarations follow the "=" instead: 

   Production          =  NonTerminal [ FormalAttributes ] 
                            "=" [ LocalDeclarations ] /* C and C++ */
                            Expression "." . 

Any identifier appearing in a production that was not previously declared as a
terminal token is considered to be the name of a NonTerminal, and there must

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
蜜臀av性久久久久蜜臀aⅴ四虎 | 91视频国产观看| 色婷婷综合久久久| 精品区一区二区| 一区二区三区不卡视频| 国产一区日韩二区欧美三区| 在线视频观看一区| 欧美国产成人精品| 美国毛片一区二区三区| 色欧美日韩亚洲| 国产欧美日韩在线观看| 日韩高清不卡在线| 欧美亚洲综合久久| 中文字幕在线不卡| 国产毛片精品国产一区二区三区| 欧美综合一区二区三区| 中文字幕一区在线| 国内外成人在线| 欧美一区二区在线免费观看| 亚洲精品视频自拍| 成人精品视频一区二区三区尤物| 欧美大片日本大片免费观看| 午夜精品久久久久影视| 91丨九色porny丨蝌蚪| 欧美国产精品中文字幕| 看片网站欧美日韩| 91精品国产福利在线观看| 亚洲日本电影在线| 色呦呦日韩精品| 亚洲日本欧美天堂| 91蜜桃传媒精品久久久一区二区| 国产精品久久久久久妇女6080| 国产一区二区调教| 久久久久久97三级| 国产一区91精品张津瑜| 久久久久久**毛片大全| 国产精品99精品久久免费| 国产亚洲精品中文字幕| 国产精品一区二区在线看| 国产亚洲精品aa| 国产高清亚洲一区| 国产精品乱码一区二三区小蝌蚪| 成人av影视在线观看| 国产精品久久久久影院老司| 99精品欧美一区二区三区综合在线| 国产日韩欧美亚洲| 99在线精品观看| 亚洲一区二区三区四区的 | 天堂午夜影视日韩欧美一区二区| 欧美综合欧美视频| 日韩精品久久理论片| 日韩欧美亚洲国产精品字幕久久久| 美女高潮久久久| 国产日韩欧美精品电影三级在线 | 在线免费亚洲电影| 亚洲va欧美va天堂v国产综合| 欧美人牲a欧美精品| 久久国产精品免费| 久久精品日韩一区二区三区| 成人精品亚洲人成在线| 亚洲成人动漫精品| 欧美成人一级视频| 99精品在线观看视频| 一区二区三区加勒比av| 日韩欧美一级二级三级久久久| 国产在线精品一区二区| 亚洲婷婷综合久久一本伊一区| 欧美日韩一区成人| 国产河南妇女毛片精品久久久| 亚洲欧洲一区二区在线播放| 欧美视频中文字幕| 黄色日韩三级电影| 亚洲精品国产精华液| 精品国产三级a在线观看| 99精品热视频| 国产乱码字幕精品高清av| 亚洲一区在线观看免费观看电影高清 | 亚洲一区国产视频| 久久精品欧美日韩精品| 欧美三级视频在线| 懂色一区二区三区免费观看| 婷婷久久综合九色综合绿巨人| 国产性色一区二区| 欧美一区二区三区婷婷月色| 91首页免费视频| 国产一区二区0| 免费久久99精品国产| 亚洲精品欧美专区| 中文字幕欧美国产| 欧美一区二区三区公司| 成人黄色av电影| 亚洲成人资源在线| 国产精品福利一区| 国产日韩精品视频一区| 欧美日韩成人一区| 成人黄色在线看| 蜜臀久久久99精品久久久久久| 中文字幕一区二区三区四区不卡| 精品久久一二三区| 欧美日韩精品高清| 成人妖精视频yjsp地址| 免费成人在线观看视频| 亚洲精品久久7777| 日本一区二区三区久久久久久久久不 | 亚洲色图丝袜美腿| 精品国产凹凸成av人导航| 日本精品一区二区三区四区的功能| 国内久久精品视频| 天天爽夜夜爽夜夜爽精品视频| ㊣最新国产の精品bt伙计久久| 日韩亚洲欧美在线观看| 欧美日免费三级在线| 99精品偷自拍| 成人永久aaa| 国产综合色视频| 韩国一区二区视频| 日韩av在线免费观看不卡| 亚洲一区二区黄色| 一区二区三区在线看| 一区二区三区国产精华| 亚洲色图欧洲色图婷婷| 国产精品久久久久影视| 欧美高清在线一区二区| 精品久久久久久久久久久久久久久 | 午夜精品一区二区三区电影天堂| 亚洲视频图片小说| 国产精品美女久久久久久久久久久 | 国产成人精品一区二| 激情综合网最新| 另类专区欧美蜜桃臀第一页| 蜜臀va亚洲va欧美va天堂| 青青草原综合久久大伊人精品 | 精品久久久久久亚洲综合网| 91麻豆精品91久久久久同性| 日韩一级免费观看| 欧美一区在线视频| 91精品国产高清一区二区三区蜜臀 | 亚洲精品第一国产综合野| 亚洲欧洲三级电影| 亚洲日本欧美天堂| 亚洲已满18点击进入久久| 亚洲一区二区影院| 亚洲一区在线看| 国产一区高清在线| 国产成人午夜片在线观看高清观看| 国产裸体歌舞团一区二区| 国产电影一区二区三区| 99久久国产综合色|国产精品| 91欧美激情一区二区三区成人| 国产精品一区二区果冻传媒| 色哟哟一区二区在线观看| 欧美日韩激情在线| 日韩精品一区二区三区在线观看| 精品精品国产高清a毛片牛牛| 久久综合色综合88| 国产精品久久久久国产精品日日| 国产精品电影一区二区三区| 亚洲国产日韩一区二区| 亚洲一区二区三区国产| 久久av中文字幕片| 成人网页在线观看| 欧美色国产精品| 久久久精品综合| 一区二区在线观看免费视频播放| 麻豆91免费看| a4yy欧美一区二区三区| 欧美精品免费视频| 久久精品视频网| 香港成人在线视频| 国产精品69毛片高清亚洲| 9191成人精品久久| 中文字幕不卡在线观看| 日韩精品亚洲专区| 国产精品小仙女| 欧美色倩网站大全免费| 欧美一区二区三区系列电影| 亚洲精品免费一二三区| 麻豆一区二区三| 一本久久综合亚洲鲁鲁五月天 | 韩国精品主播一区二区在线观看| 91首页免费视频| 日韩欧美一二三| 午夜激情一区二区三区| 成人三级伦理片| 日韩欧美电影一区| 亚洲综合一区二区三区| 国产乱码精品一区二区三| 欧美日韩国产一级| 一级日本不卡的影视| 国产一区二区电影| 欧美日韩国产片| 亚洲欧美乱综合| 国产成人精品一区二| 久久久九九九九| 久久精品国产亚洲高清剧情介绍| 欧美综合一区二区| 亚洲图片激情小说| av一区二区三区| 日韩免费观看高清完整版| 美女视频黄久久|