SlideShare a Scribd company logo
Variability-Aware Parsing
                            in the Presence of
   Lexical Macros and Conditional Compilation




                                                 Christian Kästner
                                                 Paolo G. Giarrusso
                                                 Tillmann Rendel
                                                 Sebastian Erdweg
                                                 Klaus Ostermann
                                                 Thorsten Berger
Parsing C Code
without Preprocessing



                        Christian Kästner
                        Paolo G. Giarrusso
                        Tillmann Rendel
                        Sebastian Erdweg
                        Klaus Ostermann
                        Thorsten Berger
Viewer Discretion Is Advised
Linux
Kernel
10,000 features, 6 million lines of C code
Parse and Type check
               all configurations of the
                               entire Linux     kernel

   10,000 features, 6 million lines of C code
greet.c


                          printf   …       VWORLD          VBYE        main


           AST with                msg          ε      msg         ε   printf

Variability Information   ¬ (WORLD ˄BYE)
                                                                       msg
                                           true -> (WORLD v BYE)
Variability-Aware Analysis
                 Type System
                 Static Analysis
                 Bug Finding
                 Testing
                 Model Checking
                 Theorem Proving
                 …
Parsing C without Preprocessing
Macro expansion                 Undisciplined
needed for parsing               annotations                                       Alternative macros




                                                     ?
                     ?                                                         ?
                                                     greet.c



                         + printf           VWORLD         VBYE       + main


                                    + msg        ε     + msg      ε   printf


                                                                       msg
Previous Solutions

Disciplined Subset
      Requires Code Preparation

Heuristics and Partial Analysis
     Inaccurate, False Positives

Brute Force
     Infeasible Effort
https://github.com/ckaestne/TypeChef

TypeChef
                                                         Variability-Aware
                                               Parser-Framework

                        (                                                                +
                            2
    Variability-Aware           *                   Variability-Aware
                                    3                                            *               VA
         Lexer                          )
                                            +          Parser
                                             4A
                                              5¬A                            2       3       4        5


                                                                             Variability-Aware

                                                                             Analysis
Variability-Aware       Lexer




            (
                2
                    *
Variability-Aware   Lexer
353 included header files
      0                             per C file



   8590 macros
      0             per C file



   1387 conditional macros
      0                          per C file




335490 token
     0          per C file



    72 % conditional
     0                                        2.6.33.3
                                              X86
Variability-Aware   Parsing

(   2   *   3   )   +   4A 5¬A
                                                    +

                                            *               VA

                                        2       3       4        5
Undisciplined Annotations


2   *   (A   3    +   4   )A                   VA

                                   *                        +

                               2       +                *       4

                                   3       4        2       3
Partial Errors


2   *   (A   3   +   4   )                    VA

                                  *           Parse Error
                                              Expected + or EOF,
                                              but found ) at 1:7
                              2       +

                                  3       4
true
       (   3   +   4A   (¬A 4¬A˄ +¬A˄ 6¬A
                                B    B      )¬A   )
true
(      3   +   4A   (¬A 4¬A˄ +¬A˄ 6¬A
                            B    B      )¬A   )
3
        true
(   3      +   4A   (¬A 4¬A˄ +¬A˄ 6¬A
                            B    B      )¬A   )
3
        true
(   3   +   4A   (¬A 4¬A˄ +¬A˄ 6¬A
                         B    B      )¬A   )
A
3                4A   (¬A 4¬A˄ +¬A˄ 6¬A
                              B    B      )¬A   )

(   3   +

                 4A   (¬A 4¬A˄ +¬A˄ 6¬A
                              B    B      )¬A   )
            ¬A
4             A
3                4A       (¬A 4¬A˄ +¬A˄ 6¬A
                                  B    B      )¬A   )

(   3   +

                 4A       (¬A 4¬A˄ +¬A˄ 6¬A
                                  B    B      )¬A   )
            ¬A
4                  A
3                4A    (¬A 4¬A˄ +¬A˄ 6¬A
                               B    B            )¬A    )

(   3   +
                      Next Token:
                 4A    (¬A 4¬A˄ +¬A˄ 6¬A
                               B    B            )¬A    )
                      ctx -> tok: Consume
            ¬A        ctx ->¬tok: Skip
                      else:       Split (ctx ˄pc) andctx ˄ ¬pc)
                                                     (
4                     A
3                4A   (¬A 4¬A˄B +¬A˄ 6¬A
                                    B      )¬A   )

(   3   +

                 4A   (¬A 4¬A˄ +¬A˄ 6¬A
                              B    B       )¬A   )
            ¬A
4                          A
3                4A   (¬A 4¬A˄B +¬A˄ 6¬A
                                    B      )¬A   )

(   3   +

                 4A   (¬A 4¬A˄ +¬A˄ 6¬A
                              B    B       )¬A   )
            ¬A
4                                  A
3                4A   (¬A 4¬A˄B +¬A˄ 6¬A
                                    B          )¬A   )

(   3   +

                 4A   (¬A 4¬A˄ +¬A˄ 6¬A
                              B    B           )¬A   )
            ¬A
4                                        A
3                4A   (¬A 4¬A˄B +¬A˄ 6¬A
                                    B      )¬A       )

(   3   +

                 4A   (¬A 4¬A˄ +¬A˄ 6¬A
                              B    B       )¬A       )
            ¬A
4                                        A
3           4A        (¬A 4¬A˄B +¬A˄ 6¬A
                                    B      )¬A       )

(   3   +

            4A        (¬A 4¬A˄ +¬A˄ 6¬A
                              B    B       )¬A       )
                 ¬A
4                                   A
3           4A   (¬A 4¬A˄B +¬A˄ 6¬A
                               B      )¬A       )

(   3   +

            4A   (¬A 4¬A˄ +¬A˄ 6¬A
                         B    B       )¬A       )
                   ¬A
4                                    A
3           4A   (¬A 4¬A˄B +¬A˄ 6¬A
                               B       )¬A       )

(   3   +         ¬A˄B
                       4¬A˄ +¬A˄ 6¬A
                           B    B      )¬A       )
            4A   (¬A
                       4¬A˄ +¬A˄ 6¬A
                           B    B      )¬A       )
                 ¬A˄¬B
4                                    A
3           4A   (¬A 4¬A˄B +¬A˄ 6¬A
                               B       )¬A       )

(   3   +         4      ¬A˄B
                       4¬A˄ +¬A˄ 6¬A
                           B    B      )¬A       )
            4A   (¬A
                       4¬A˄ +¬A˄ 6¬A
                           B    B      )¬A       )
                 ¬A˄¬B
4                                    A
3           4A   (¬A 4¬A˄B +¬A˄ 6¬A
                               B       )¬A       )

(   3   +         4           ¬A˄B
                       4¬A˄ +¬A˄ 6¬A
                           B    B      )¬A       )
            4A   (¬A
                       4¬A˄ +¬A˄ 6¬A
                           B    B      )¬A       )
                 ¬A˄¬B
4                                     A
3           4A   (¬A + 4¬A˄B +¬A˄ 6¬A
                                 B      )¬A       )

(   3   +         4    6           ¬A˄B
                       4¬A˄ +¬A˄ 6¬A
                           B    B       )¬A       )
            4A   (¬A
                       4¬A˄ +¬A˄ 6¬A
                           B    B       )¬A       )
                 ¬A˄¬B
4                                     A
3           4A   (¬A + 4¬A˄B +¬A˄ 6¬A
                                 B      )¬A       )

(   3   +         4    6           ¬A˄B
                       4¬A˄ +¬A˄ 6¬A
                           B    B       )¬A       )
            4A   (¬A
                       4¬A˄B +¬A˄ 6¬A
                                 B      )¬A       )
                           ¬A˄¬B
4                                     A
3           4A   (¬A + 4¬A˄B +¬A˄ 6¬A
                                 B      )¬A       )

(   3   +         4    6           ¬A˄B
                       4¬A˄ +¬A˄ 6¬A
                           B    B       )¬A       )
            4A   (¬A
                       4¬A˄B +¬A˄ 6¬A
                                 B      )¬A       )
                              ¬A˄¬B
4                                     A
3           4A   (¬A + 4¬A˄B +¬A˄ 6¬A
                                 B      )¬A       )

(   3   +         4    6           ¬A˄B
                       4¬A˄ +¬A˄ 6¬A
                           B    B       )¬A       )
            4A   (¬A
                       4¬A˄B +¬A˄ 6¬A
                                 B      )¬A       )

                              6    ¬A˄¬B
4                                              A
3               4A       (¬A 4¬A˄B +¬A˄ 6¬A
                                       B         )¬A       )

(   3   +
                               4¬A˄ +¬A˄ 6¬A
                                   B    B
                4A       (¬A                     )¬A       )
                               4¬A˄B +¬A˄ 6¬A
                                         B

                VB                          ¬A
            +        6
        4       6
4                                             A
3               4A       (¬A 4¬A˄B +¬A˄ 6¬A
                                       B        )¬A        )

(   3   +
                               4¬A˄ +¬A˄ 6¬A
                                   B    B
                4A       (¬A                    )¬A        )
                               4¬A˄B +¬A˄ 6¬A
                                         B
                                                      ¬A
                VB
            +        6
        4       6
3                        4A   (¬A 4¬A˄B +¬A˄ 6¬A     )¬A
                                            B          true
(            3       +                                        )
                                    4¬A˄ +¬A˄ 6¬A
                                        B    B
                         4A   (¬A                    )¬A
        VA                          4¬A˄B +¬A˄ 6¬A
                                              B

    4       VB
        +        6
    4        6
4A   (¬A 4¬A˄B +¬A˄ 6¬A
                                            B        )¬A       true
(            3       +                                     )
                                    4¬A˄ +¬A˄ 6¬A
                                        B    B
    +                    4A   (¬A                    )¬A
3       VA                          4¬A˄B +¬A˄ 6¬A
                                              B

    4       VB
        +        6
    4        6
Variability-Aware
Parser Combinator Library
for Scala
Variability-Aware   Parsers
GNU C + cpp     Java + Antenna
Parsing Linux



Variability in Build System (kbuild)
            and with #ifdef

Variability Model (kconfig)            2.6.33.3
                                       X86
7665 C files (x86)
    0
  30 seconds per file
    0                        (median)



  85 hours total
    0
  4.1 % overhead
    0              (undiscipl.)


     0
     0 syntax errors                    2.6.33.3
                                        X86
Parser
Variability-Aware   Type System
                    Module System
                    Static Analysis
                    Bug Finding
                    Testing
                    Model Checking
                    Theorem Proving
                    Editor Support
                    Code Transform.
                    …
Variability-Aware Parsing
                                   in the Presence of
          Lexical Macros and Conditional Compilation



                                                                         Variability-Aware
                                                               Parser-Framework

                                        (                                                                +
                                            2
                Variability-Aware               *                   Variability-Aware
                                                    3                                            *               VA
                     Lexer                              )
                                                            +          Parser
                                                             4A
                   (macros, includes)
                                                              5¬A         (split & join)     2       3       4        5




https://github.com/ckaestne/TypeChef

More Related Content

Recently uploaded

Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
ViralQR
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 

Recently uploaded (20)

Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Variability-Aware Parsing -- OOPSLA Talk

  • 1. Variability-Aware Parsing in the Presence of Lexical Macros and Conditional Compilation Christian Kästner Paolo G. Giarrusso Tillmann Rendel Sebastian Erdweg Klaus Ostermann Thorsten Berger
  • 2. Parsing C Code without Preprocessing Christian Kästner Paolo G. Giarrusso Tillmann Rendel Sebastian Erdweg Klaus Ostermann Thorsten Berger
  • 4.
  • 6. 10,000 features, 6 million lines of C code
  • 7. Parse and Type check all configurations of the entire Linux kernel 10,000 features, 6 million lines of C code
  • 8. greet.c printf … VWORLD VBYE main AST with msg ε msg ε printf Variability Information ¬ (WORLD ˄BYE) msg true -> (WORLD v BYE)
  • 9. Variability-Aware Analysis Type System Static Analysis Bug Finding Testing Model Checking Theorem Proving …
  • 10. Parsing C without Preprocessing
  • 11. Macro expansion Undisciplined needed for parsing annotations Alternative macros ? ? ? greet.c + printf VWORLD VBYE + main + msg ε + msg ε printf msg
  • 12.
  • 13.
  • 14. Previous Solutions Disciplined Subset Requires Code Preparation Heuristics and Partial Analysis Inaccurate, False Positives Brute Force Infeasible Effort
  • 15. https://github.com/ckaestne/TypeChef TypeChef Variability-Aware Parser-Framework ( + 2 Variability-Aware * Variability-Aware 3 * VA Lexer ) + Parser 4A 5¬A 2 3 4 5 Variability-Aware Analysis
  • 16. Variability-Aware Lexer ( 2 *
  • 18. 353 included header files 0 per C file 8590 macros 0 per C file 1387 conditional macros 0 per C file 335490 token 0 per C file 72 % conditional 0 2.6.33.3 X86
  • 19. Variability-Aware Parsing ( 2 * 3 ) + 4A 5¬A + * VA 2 3 4 5
  • 20. Undisciplined Annotations 2 * (A 3 + 4 )A VA * + 2 + * 4 3 4 2 3
  • 21. Partial Errors 2 * (A 3 + 4 ) VA * Parse Error Expected + or EOF, but found ) at 1:7 2 + 3 4
  • 22. true ( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A )
  • 23. true ( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A )
  • 24. 3 true ( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A )
  • 25. 3 true ( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A )
  • 26. A 3 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  • 27. 4 A 3 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  • 28. 4 A 3 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ( 3 + Next Token: 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ctx -> tok: Consume ¬A ctx ->¬tok: Skip else: Split (ctx ˄pc) andctx ˄ ¬pc) (
  • 29. 4 A 3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A ) ( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  • 30. 4 A 3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A ) ( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  • 31. 4 A 3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A ) ( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  • 32. 4 A 3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A ) ( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  • 33. 4 A 3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A ) ( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  • 34. 4 A 3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A ) ( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  • 35. 4 A 3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A ) ( 3 + ¬A˄B 4¬A˄ +¬A˄ 6¬A B B )¬A ) 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A˄¬B
  • 36. 4 A 3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A ) ( 3 + 4 ¬A˄B 4¬A˄ +¬A˄ 6¬A B B )¬A ) 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A˄¬B
  • 37. 4 A 3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A ) ( 3 + 4 ¬A˄B 4¬A˄ +¬A˄ 6¬A B B )¬A ) 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A˄¬B
  • 38. 4 A 3 4A (¬A + 4¬A˄B +¬A˄ 6¬A B )¬A ) ( 3 + 4 6 ¬A˄B 4¬A˄ +¬A˄ 6¬A B B )¬A ) 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A˄¬B
  • 39. 4 A 3 4A (¬A + 4¬A˄B +¬A˄ 6¬A B )¬A ) ( 3 + 4 6 ¬A˄B 4¬A˄ +¬A˄ 6¬A B B )¬A ) 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A ) ¬A˄¬B
  • 40. 4 A 3 4A (¬A + 4¬A˄B +¬A˄ 6¬A B )¬A ) ( 3 + 4 6 ¬A˄B 4¬A˄ +¬A˄ 6¬A B B )¬A ) 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A ) ¬A˄¬B
  • 41. 4 A 3 4A (¬A + 4¬A˄B +¬A˄ 6¬A B )¬A ) ( 3 + 4 6 ¬A˄B 4¬A˄ +¬A˄ 6¬A B B )¬A ) 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A ) 6 ¬A˄¬B
  • 42. 4 A 3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A ) ( 3 + 4¬A˄ +¬A˄ 6¬A B B 4A (¬A )¬A ) 4¬A˄B +¬A˄ 6¬A B VB ¬A + 6 4 6
  • 43. 4 A 3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A ) ( 3 + 4¬A˄ +¬A˄ 6¬A B B 4A (¬A )¬A ) 4¬A˄B +¬A˄ 6¬A B ¬A VB + 6 4 6
  • 44. 3 4A (¬A 4¬A˄B +¬A˄ 6¬A )¬A B true ( 3 + ) 4¬A˄ +¬A˄ 6¬A B B 4A (¬A )¬A VA 4¬A˄B +¬A˄ 6¬A B 4 VB + 6 4 6
  • 45. 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A true ( 3 + ) 4¬A˄ +¬A˄ 6¬A B B + 4A (¬A )¬A 3 VA 4¬A˄B +¬A˄ 6¬A B 4 VB + 6 4 6
  • 47. Variability-Aware Parsers GNU C + cpp Java + Antenna
  • 48. Parsing Linux Variability in Build System (kbuild) and with #ifdef Variability Model (kconfig) 2.6.33.3 X86
  • 49. 7665 C files (x86) 0 30 seconds per file 0 (median) 85 hours total 0 4.1 % overhead 0 (undiscipl.) 0 0 syntax errors 2.6.33.3 X86
  • 50. Parser Variability-Aware Type System Module System Static Analysis Bug Finding Testing Model Checking Theorem Proving Editor Support Code Transform. …
  • 51. Variability-Aware Parsing in the Presence of Lexical Macros and Conditional Compilation Variability-Aware Parser-Framework ( + 2 Variability-Aware * Variability-Aware 3 * VA Lexer ) + Parser 4A (macros, includes) 5¬A (split & join) 2 3 4 5 https://github.com/ckaestne/TypeChef