Upload
wafa111222
View
5
Download
4
Embed Size (px)
DESCRIPTION
مترجمات
Citation preview
YACC
- :
+
Lexical Analyzer LEX , . LEX .
LEX , . LEX , ( LEX ) .
LEX , Generator Host Language.
Code LEX . . LEX .
C.
LEX ( Source) , yylex.
yylex Expressions . (1) LEX:
+-------+
Source -> | Lex | -> yylex
+-------+
+-------+
Input -> | yylex | -> Output
+-------+
(1) LEX LEX , Lexical, LEX Parser Lexical Analysis Phase, LEX YACC . LEX , YACC Context Free Grammar Tokens, LEX YACC .
LEX Parser .
- LEX: LEX :
{Definitions}
%%
{Rules}
%%
{User subroutines}
Definitions %% , LEX : %% , .
LEX Rules . ( ), .
, :
integer printf("found keyword INT");
" integer" " found keyword INT " .
C. C .
, :
colour printf("color");
mechanise printf("mechanize");petrol printf("gas");
- LEX Characters (,,,...) . LEX , :
LEX : " \ [ ] ^ - ? . * + | ( ) $ / { } % < >
" , xyz"++" xyz++ "xyz++".
[], [abc] a, b c. [] : \ , - , ^. [a-z0-9] a z, , ( - ) . [^abc] a b c [^a-zA-Z] . ( \ ) Escape.
ab?c ac abc. a* a . a+ a . [a-z]+ . [A-Za-z][A-Za-z0-9] . (ab|cd) ab cd. {digit} digit . LEX . YACC Parser . Parser Generators . Context Free Grammar.
Bison
YACC C, . YACC S.C.Johnson Bell. - YACC:
YACC :C and parser declarations
%%
Grammar rules and actions
%%
C subroutines YACC Tokens . Start Symbol .%start program YACC . . YACC . Productions . , Non-Terminal Symbol , , (:). YACC C, main() yyparse(), . yyerror() .
, , , . PAGE - 8 -