zoukankan      html  css  js  c++  java
  • 编译原理笔记

    第二章

    language generated by regular expression is written as L(r).

    this language depends on the character set that is available. set elements are

    reffered as symbols. this set of legal symbols is called the alphabet and is usually

    written as the Greek symbol ∑ sigma.

    2.2.1 definition of regular expressions

    1. basic regular expression

    2. choice of alternatives:  |

    3. concatenation: rs

    4. repetition : Kleene closure  r*

    5.parentheses :()

    aNbaN

    pumping lemma

    2.2.2 extensions to regular expressions正则表达式扩展

    1. 一个或多个 one or more repetitions: +

    2.  任意字符 any character : .

    3.字符范围 a range of characters: [a-z]

    4. any character not in a given set: [^abc]

    5. optional ?

    2.2.3 regular expressions for programming lanaguage Tokens

    1.reserved words , keywords: while , if

    2.special symbols : ++ , :=

    3.identifiers: sequences of letters and digits begin with a letter

    4.literals: numeric constants, 42, 3.14159, string literals, "hello, world" ,'a'

    1) numbers:

    nat = [0-9]+

    signedNat = (+|-)? nat

    number = signedNat("."nat)?(E signedNat)?

    2) reserved words and identifiers

    reserved = if | while | do | ...

    letter = [a-zA-Z]

    digit = [0-9]

    identifier = letter(letter|digit)*

    3)comments:

    /**/ ad hoc method

    (* this is (* a Modula-2 *) comment *) 

    we have noted in expample 2.3 that regular expressions

    cannot express counting operations. In practice, we use a simple conter

    as an ad hoc solution to this problem(see the exercises).

    4) ambiguity, white space , and lookahead

    1.disambiguating rules

    principle of longest substring

    token delimiters

    free format, fixed format, offside rule(利用缩进来格式化)

  • 相关阅读:
    bzoj 3456 城市规划 —— 分治FFT / 多项式求逆 / 指数型生成函数(多项式求ln)
    洛谷 P4721 [模板]分治FFT —— 分治FFT / 多项式求逆
    CF 438 E & bzoj 3625 小朋友和二叉树 —— 多项式开方
    Codeforces 447
    Codeforces 1099
    Codeforces 991
    Codeforces 994
    Codeforces 989
    Codeforces 1084
    xj膜你赛(n-1)
  • 原文地址:https://www.cnblogs.com/cute/p/2174535.html
Copyright © 2011-2022 走看看