SlideShare a Scribd company logo
1 of 51
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

UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewDianaGray10
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxMarkSteadman7
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governanceWSO2
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingWSO2
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxFIDO Alliance
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaWSO2
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityVictorSzoltysek
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data SciencePaolo Missier
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringWSO2
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformWSO2
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseWSO2
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAnitaRaj43
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهMohamed Sweelam
 

Recently uploaded (20)

UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهله
 

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 HubspotMarius 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 ChatGPTExpeed 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 EngineeringsPixeldarts
 
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 HealthThinkNow
 
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.pdfmarketingartwork
 
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 2024Neil 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 2024Albert 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 InsightsKurio // 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 2024Search 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 summarySpeakerHub
 
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 IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit 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 managementMindGenius
 
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