Design and Implementation of the fifth job ---- lexical analysis program

Lexical analysis program ( Lexical  Analyzer ) requirements:

- stream from a source program composed of character scan left to right

- identify the lexical meaning of the word ( Lexemes )

- Return word record (word class, the word itself)

- filtered spaces

- skip comments

- lexical errors found

 

Program Structure:

Input: character stream (input what way, what data structure stored)

deal with:

- Traverse (What traversal)

- lexical rules

Output: word stream (what output form)

- tuple

 

Word class:

1. Identifier (10)

2. unsigned (11)

3. Leave the word (the word one yard)

4. Operator (word one yard)

5. delimiter (word one yard)

 

Word symbols

Species do not code

Word symbols

Species do not code

begin

1

:

17

if

2

:=

18

then

3

<

20

while

4

<=

21

do

5

<>

22

end

6

>

23

l(l|d)*

10

>=

24

dd*

11

=

25

+

13

;

26

-

14

(

27

*

15

)

28

/

16

#

0

 

Guess you like

Origin www.cnblogs.com/sgczw/p/11655209.html