Lexical Analysis 1

Source: Internet
Author: User

The attributes of the lexical notation, which are used to further differentiate the attributes within the token.


<a1,a2,a3,a4,..., an> becomes n-ary

A1 becomes the first dollar, A2 is called Second dollar, analogy .... ;

For example: Position = initial + rate * 60 notation and attributes

<id, pointer to the position entry in the symbol table, the second element represents the property

<assign_op>, assignment numbers--separate as tokens, do not require a second element to be distinguished as attributes

<id, pointer to initial entry in symbol table > second Element representation property

<add_op> separate as a notation, no need to distinguish the second element as an attribute

<id, pointer to rate entry in symbol table > second Element representation property

<mul_op> separate as a notation, no need to distinguish the second element as an attribute

<number, integer value 60>


After the lexical analysis is complete, the tokens and attributes are returned each time.

Second, string and language

-Alphabet: A limited set of symbols, such as ={0, 1}

-string: A poor sequence of symbols, such as 0110

-language: A string set on the alphabet {0, 00,000, ... }

The operation of the string:

-Connect (product) XY, s empty string = empty string s=s

-The power s of the 0-time square is empty, s of the I-squared-=s of the i-1-th square s


The language of the operation:

-and: L∪m = {s|s∈l or s∈m}

-Connection: Lm={st|s∈l and T∈m}, that is, the first part belongs to the front, the latter part belongs to the back

-Power: 0 Power of L is {&},l I power is L power l

-Closures: L*=l0∪l1∪l1∪ ...., the number part refers to the second power

-Positive closure: l + = L0∪l1∪ ..., the number part refers to the second power


Examples:

L:{a,b,c,d,..., z,a,b,c,... z},d:{0,1,2,3,... 9}

L∪d: A sentence of length one, as a letter or a number

LD: A sentence of length 2, the first part is a letter, the latter part is a number

L6: A sentence of length 6, 6 symbols are letters

l*: letter string of any length, including empty string

d+: An unsigned integer is defined

L (l∪d) *: Is the definition of the letter or number identifier that we define as the beginning of the alphabet. The length is not fixed, * can be repeated multiple times.

The disadvantage is that it is not easy for the computer to handle the operation.

It is because this is not convenient for computer processing, so the formal type formally began to enter the field of vision ...



Regular type


Formal definition of language notes

& {&} I use the & symbol instead of the empty one, and I don't know how to find that symbol at the moment.

A {a} a∈ alphabet

(r) | (s) L (R) ∪l (s) r,s is a regular type

(r) (s) L (R) L (s) r,s is a regular type

(r) * (L (R)) * R is a regular type

(r) L (R) r is the normal type


Convention: ((a) (b) *) | (c) equivalent to Ab*|c

Examples:

The Alphabet ={a,b}, the following formula:

-a|b {A, B}

-(A|B) (a|b) {AA,AB,BA,BB}

-AA|AB|BA|BB {AA,AB,BA,BB}

-a* all sets of strings consisting of the letter A, including empty strings

-(A|B) * All strings consisting of a and B, including empty strings

-(00|11| ((01|10) (00|11) * (01|10))) * Even several 0 and an even number of 1, all the 01 strings required by the symbol, are the sentences under the regular rules. For example: 01001101000010000010111001 is the normal sentence above.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.