![]() ![]() Three parts: Definitions, Rules, User code Use “%%” as a delimiter for each part First part: Definitions Options used by flex inside the scanner Defines variables & macros Code within “% (Grammar) Rules section (details) config_parser.y Synonyms: lexical analyzer, scanner, lexer, tokenizer flex is fast Lex Lex introduction Input specification (*.l) flex You can control the name of generated file lex.yy.c C compiler Lexical Analyzer input stream token stream You generate the lexical analyzer by using flexġ6 Lex Input specification for lex – the “program” data \n\n\n \EOF Lexical Analyzer input stream token stream PROPERTY VALUE PROPERTY VALUE Output defined by actions in parser specification (often an in-memory representation of input) Structural Analyzer token streamġ5 Lex introduction Input specification (*.l) lex.yy.c input stream Lex & YACC overview server_host localhost \n server_port 1111 \n table marks \n # This data directory may be an absolute or relative path. tokenizing or lexical analysis) Parsing, i.e., analysis of structure and syntax according to a grammar (i.e., a set of rules) flex is the scanner generator (open source) Fast Lex for lexical analysis YACC is the parser generator Yet Another Compiler Compiler for structural and syntax analysis Lex and YACC work together Generated scanner drives the generated parser We use flex (fast Lex) and Bison (GNU YACC) There are myriads of other tools for Java, C++, …, some of which combine Lex/Yacc into one tool (e.g., javacc)ġ2 Objectives for today Cover the basics of Lex & YaccĮverybody should have an appreciation of the potential of these tools There is a lot more detail that remains unsaid To challenge you Patterns (TABLE TABLE-NAME)+ TABLE TABLE-NAME TABLE TABLE-NAME TABLE TABLE-NAME … Regular expressions (formal languages) Extended regular expressions (UNIX)ġ1 Scanning & parsing II Parsing is really two steps Written by developer Specification Specification Generator Generated code Generator Other code Written by developer Other code Compiler / Linker Execut- ableĩ Scanning & parsing I server_host localhost \n server_port 1111 \n table marks \n # This data PROPERTY VALUE PROPERTY VALUE … Scanning PROPERTY VALUE (TABLE TABLE-NAME)+ Parsing Verify content, add to data structures, … Processingġ0 Regular expressions (TABLE TABLE-NAME)+ data Tokensħ Scenarios Where we’d like to safe time in writing a quick language processor?Ĭonceptually speaking In our storage servers Languages Data description language Script language Markup language System configurations Workload generation Languages Data schema & data Query language Output formatting (Web, Latex, PDF, Word, Excel) Storage server configuration Benchmarking data \n\n\n \EOF PROPERTY VALUE (TABLE TABLE-NAME)+ server_host localhost server_port 1111 table marks data_directory. Many of the videos under tips & tricks are from him too Short video about CoursePeer To sign up and auto-enrol under ECE297, use this link Will have a quick demo and use it on Wednesday for our Q&A sessionģ Know your tools! Can we generate code based on a specification of what we want? Is the specification simpler than writing a program for doing the same task? Fully automated program generation has been a dream since the early days of computing.Ĥ Where do we need parsing in the storage server?ĥ Where do we need parsing in the storage server?Ĭonfiguration file (file) Bulk loading of data files (file) Protocol messages (network) Command line arguments (string)Ħ Parsing PROPERTY VALUE server_host localhost server_port 1111ĭnf – the way the disk may see it server_host localhost \n server_port 1111 \n table marks \n # This data directory may be an absolute or relative path. Hans-Arno Jacobsen ECE 297 Powerful, but not easyĢ CoursePeer – try it out! Developed by a former ECE297 student Submissions: 99 Average for A2: 71% Early submission bonus: 1 Full marks: 5 16 teams attempted nonce bonus 7 got full marks 7 teams attempted ACC bonus Can we generate code to support mundane coding tasks and safe time? Scanning & Parsing with Lex and YACC Give you an example for Milestone 1.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |