亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
欧美日韩精品高清| 国产精品久久久久三级| 国产日韩欧美精品一区| 一区二区三区日本| 国产精品亚洲人在线观看| 欧美肥妇free| 亚洲欧美一区二区久久| 高清久久久久久| 91精品国产麻豆国产自产在线| 中文字幕亚洲在| 国产一区欧美日韩| 欧美色老头old∨ideo| 国产精品每日更新| 国产精品一品视频| 日韩欧美美女一区二区三区| 亚洲妇女屁股眼交7| 色综合天天综合网国产成人综合天 | 欧美色涩在线第一页| 国产精品久久久久久一区二区三区 | 91麻豆精品国产91久久久久久久久| 中文字幕欧美一区| 国产精品香蕉一区二区三区| 欧美一二三区精品| 天天影视涩香欲综合网| 色猫猫国产区一区二在线视频| 国产精品嫩草99a| 国产99久久久国产精品免费看| 精品少妇一区二区三区视频免付费| 三级不卡在线观看| 欧美网站一区二区| 亚洲电影在线免费观看| 91九色02白丝porn| 亚洲一卡二卡三卡四卡无卡久久 | 欧美精品在线一区二区| 亚洲国产精品久久人人爱蜜臀| 在线一区二区三区| 亚洲国产精品久久艾草纯爱| 色av综合在线| 亚洲 欧美综合在线网络| 91精品福利视频| 夜夜精品视频一区二区 | 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 国产很黄免费观看久久| 国产色产综合产在线视频| 国产麻豆日韩欧美久久| 亚洲国产成人在线| av电影天堂一区二区在线| 亚洲日本在线a| 在线免费不卡电影| 日韩精品一卡二卡三卡四卡无卡| 91精品欧美福利在线观看| 麻豆久久久久久久| 国产欧美日韩精品一区| 波多野结衣一区二区三区| 亚洲欧洲精品成人久久奇米网| 91老司机福利 在线| 性做久久久久久免费观看| 日韩一级免费观看| 国产成人激情av| 亚洲激情在线激情| 欧美成人精品福利| 成人动漫在线一区| 亚洲成人1区2区| 欧美精品一区男女天堂| 9l国产精品久久久久麻豆| 亚洲成人一区在线| 久久久久久97三级| 欧日韩精品视频| 国精品**一区二区三区在线蜜桃| 国产精品成人免费 | 97久久精品人人做人人爽50路| 亚洲国产一二三| 久久久久久久久久久久电影 | 国产精品国产精品国产专区不蜜 | 99视频一区二区| 日本午夜精品一区二区三区电影| 国产午夜精品久久| 欧美日免费三级在线| 国产黄色精品视频| 免费国产亚洲视频| 亚洲黄色片在线观看| 久久日韩精品一区二区五区| 91黄色在线观看| 国产一区二区三区四| 亚洲动漫第一页| 国产精品乱码一区二区三区软件 | 精品国产露脸精彩对白| 一本到不卡免费一区二区| 久久99国产精品麻豆| 亚洲一区二区视频在线观看| 国产人久久人人人人爽| 欧美一区二区三区思思人| 99久久亚洲一区二区三区青草| 麻豆精品精品国产自在97香蕉| 一级日本不卡的影视| 中文字幕亚洲视频| 国产色一区二区| 久久综合九色综合欧美就去吻 | 久久精品一区二区三区不卡| 欧美人与性动xxxx| 色婷婷国产精品久久包臀| 成人综合激情网| 国产精品夜夜爽| 国产一区二区电影| 奇米精品一区二区三区在线观看| 亚洲高清视频的网址| 亚洲精品中文字幕乱码三区| 国产精品国产三级国产普通话99| 久久久久久久免费视频了| 亚洲精品一区二区在线观看| 日韩欧美一级二级| 日韩一级片网址| 日韩精品一区二区三区老鸭窝| 7777精品伊人久久久大香线蕉| 精品1区2区3区| 欧美日韩的一区二区| 欧美精品亚洲一区二区在线播放| 欧美在线观看一区| 欧美日韩在线一区二区| 欧美男男青年gay1069videost| 欧美日韩精品欧美日韩精品一| 欧美另类高清zo欧美| 日韩三级在线观看| 久久亚洲私人国产精品va媚药| 日韩三级.com| 久久久久久久久久看片| 国产精品麻豆99久久久久久| 亚洲欧美激情视频在线观看一区二区三区 | 一个色在线综合| 午夜欧美在线一二页| 日本三级亚洲精品| 国内精品免费在线观看| 国产精品一区二区久久不卡| 成人国产精品免费观看| 色菇凉天天综合网| 日韩一级视频免费观看在线| 久久综合给合久久狠狠狠97色69| 亚洲国产精品成人综合| 亚洲视频网在线直播| 亚洲第一狼人社区| 捆绑变态av一区二区三区| 国产精品亚洲第一| 91久久精品网| 精品国精品国产| 国产精品国产三级国产普通话蜜臀| 亚洲柠檬福利资源导航| 日韩av网站免费在线| 国产成人精品免费视频网站| 91久久精品一区二区| 精品少妇一区二区三区在线视频| 国产精品蜜臀av| 视频在线在亚洲| 成人va在线观看| 制服丝袜一区二区三区| 中文字幕 久热精品 视频在线 | 欧美日韩在线免费视频| 久久久www成人免费无遮挡大片| 最新日韩在线视频| 日本亚洲欧美天堂免费| 成人a区在线观看| 91精品久久久久久久99蜜桃 | 精品国产自在久精品国产| 中文字幕在线一区免费| 日本不卡一区二区三区| 成人国产精品免费观看动漫| 欧美精品v国产精品v日韩精品| 欧美激情一区三区| 日韩精品成人一区二区在线| 99久久精品免费看| www激情久久| 五月天激情综合| 99久久精品免费| 国产亚洲一区二区三区在线观看| 亚洲一本大道在线| 波多野结衣在线一区| 精品国产91亚洲一区二区三区婷婷 | 五月激情综合网| 色嗨嗨av一区二区三区| 国产网站一区二区| 蜜臀久久99精品久久久久久9 | 亚洲自拍偷拍九九九| 成人高清视频在线观看| 久久婷婷国产综合精品青草| 美女视频一区在线观看| 欧美久久久久久蜜桃| 亚洲精品日韩一| 91在线观看地址| 中文字幕一区二区不卡| 国产精品456| 久久精品男人天堂av| 国产一区二区三区精品欧美日韩一区二区三区 | 欧美日韩国产高清一区二区| 亚洲日本一区二区| jlzzjlzz欧美大全| 国产精品久久久久影院色老大| 福利电影一区二区三区| 国产日产欧美一区| 成人午夜大片免费观看| 国产精品丝袜91| 97精品超碰一区二区三区|