freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

lexyacctutorial(存儲版)

2024-11-27 00:55上一頁面

下一頁面
  

【正文】 。 expr 39。}PLLab, NTHU,Cs2403 Programming Languages 36 Works with Lex Y A C Cy y p a r s e ( )I n p u t p r o g r a m s12 + 26L E Xy y le x ( )How to work ? PLLab, NTHU,Cs2403 Programming Languages 37 Works with Lex Y A C Cy y p a r s e ( )I n p u t p r o g r a m s12 + 26L E Xy y le x ( )call yylex() [09]+ next token is NUM NUM ?+? NUM PLLab, NTHU,Cs2403 Programming Languages 38 YACC File Format %{ C declarations %} yacc declarations %% Grammar rules %% Additional C code – Comments enclosed in /* ... */ may appear in any of the sections. PLLab, NTHU,Cs2403 Programming Languages 39 Definitions Section %{ include include %} %token ID NUM %start expr It is a terminal 由 expr 開始 parse PLLab, NTHU,Cs2403 Programming Languages 40 Start Symbol ? The first nonterminal specified in the grammar specification section. ? To overwrite it with %start declaraction. %start nonterminal PLLab, NTHU,Cs2403 Programming Languages 41 Rules Section ? This section defines grammar ? Example expr : expr 39。39。T lex ? GNU flex ? a Win32 version of flex : or Cygwin : ? Lex on different machines is not created equal. PLLab, NTHU,Cs2403 Programming Languages 31 Yacc Yet Another CompilerCompiler PLLab, NTHU,Cs2403 Programming Languages 32 Introduction ? What is YACC ? – Tool which will produce a parser for a given grammar. – YACC (Yet Another Compiler Compiler) is a program designed to pile a LALR(1) grammar and to produce the source code of the syntactic analyzer of the language produced by this grammar. PLLab, NTHU,Cs2403 Programming Languages 33 How YACC Works File containing desired grammar in yacc format yacc program C source program created by yacc C piler Executable program that will parse grammar given in yacc cc or gcc PLLab, NTHU,Cs2403 Programming Languages 34 yacc How YACC Works (1) Parser generation time YACC source (*.y) C piler/linker (2) Compile time (3) Run time Token stream Abstract Syntax Tree PLLab, NTHU,Cs2403 Programming Languages 35 An YACC File Example %{include %}%token NAME NUMBER%%statement: NAME 39。} PLLab, NTHU,Cs2403 Programming Languages 25 Lex Library Routines ? yylex() – The default main() contains a call of yylex() ? yymore() – return the next token ? yyless(n) – retain the first n characters in yytext ? yywarp() – is called whenever Lex reaches an endoffile – The default yywarp() always returns 1 PLLab, NTHU,Cs2403 Programming Languages 26 Review of Lex Predefined Variables Name Function char *yytext pointer to matched string int yyleng length of matched string FILE *yyin input stream pointer FILE *yyout output stream pointer int yylex(void) call to invoke lexer, returns token char* yymore(void) return the next token int yyless(int n) retain the first n characters in yytext int yywrap(void) wrapup, return 1 if done, 0 if not done ECHO write matched string REJECT go to the next alternative rule INITAL initial start condition BEGIN condition switch start condition PLLab, NTHU,Cs2403 Programming Languages 27 User Subroutines Section ? You can use your Lex routines in the same ways you use routines in other programming languages. %{ void foo()。 REJECT。d=b*c。 a = b + c。 ID ASSIGN ID PLUS ID MULT ID SEMI ? Lex is an utility to help you rapidly generate your scanners PLLab, NTHU,Cs2403 Programming Languages 5 Lex – Lexical Analyzer ? Lexical analyzers tokenize input streams ? Tokens are the terminals of a language – English ? words, punctuation marks, … – Programming language ? Identifiers, operators, keywords, … ?
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1