Parsing - roybaer/sdcc-wiki GitHub Wiki

Table of Contents

parsing

  • happens inside SDCC.EXE

sources

  • sdcc/src/src/SDCC.lex
    • compiled using lex (flex?)
    • generates the lexer which is what recognizes groups of
characters as "words" (tokens)
  • sdcc/src/src/SDCC.y
    • compiled using bison (alternative to yacc)
    • generates the parser which takes the output of the lexer and attempts to fit them into the defined grammar
  • additional target dependent "hooks":
    • port->keywords for the "extra" port-dependent keywords
      • initialized usually in sdcc/src/src/[port]/main.c
      • passed via _ports in sdcc/src/src/SDCCmain.c
    • port->process_pragma
      • enables target-specific #pragma-s

what does it do

  • transforms C source into AST (annotated source tree or abstract source tree)
  • flow: ???

input

  • output from SDCPP preprocessor

output

  • AST - a binary tree located in memory.
    • struct for it is defined in src/SDCCast.h.
    • use --dumptree compiler option to show what is in the tree
⚠️ **GitHub.com Fallback** ⚠️