Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 1.05 KB

lexyacc.md

File metadata and controls

38 lines (27 loc) · 1.05 KB

Build Lex and Yacc

lex_yacc_library

Used to describe a lex yacc target, generate a scanner and a grammer for a compiler.

Lex and yacc are often be used together. when we compile a lex file, yy.tab.h is needed which is generated by yacc. but when we compile yy.tab.cc which is generated from the yacc file. it call the parse function which is generated by lex.

If we saparate them into 2 libraries, there will depends on each other, there is a loop dependency.

So we build the in one rule, the srcs must be a tuple of 2 elements, which are the lex and yacc file. the suffix should be l and y for C code, and should be ll and yy for c++ result.

This rule will generate a library and a header file.

Attributes:

  • recursive=True Generate resursice C scanner

lex_yacc_library also support most cc_library attributes.

Example:

lex_yacc_library(
     name = 'parser',
     srcs = [
         'line_parser.ll',
         'line_parser.yy'
     ],
     deps = [
         ":xcubetools",
     ],
     recursive = True
)