0
Variability-Aware Parsing                            in the Presence of   Lexical Macros and Conditional Compilation      ...
Parsing C Codewithout Preprocessing                        Christian Kästner                        Paolo G. Giarrusso    ...
Viewer Discretion Is Advised
LinuxKernel
10,000 features, 6 million lines of C code
Parse and Type check               all configurations of the                               entire Linux     kernel   10,00...
greet.c                          printf   …       VWORLD          VBYE        main           AST with                msg  ...
Variability-Aware Analysis                 Type System                 Static Analysis                 Bug Finding        ...
Parsing C without Preprocessing
Macro expansion                 Undisciplinedneeded for parsing               annotations                                 ...
Previous SolutionsDisciplined Subset      Requires Code PreparationHeuristics and Partial Analysis     Inaccurate, False P...
https://github.com/ckaestne/TypeChefTypeChef                                                         Variability-Aware    ...
Variability-Aware       Lexer            (                2                    *
Variability-Aware   Lexer
353 included header files      0                             per C file   8590 macros      0             per C file   1387...
Variability-Aware   Parsing(   2   *   3   )   +   4A 5¬A                                                    +            ...
Undisciplined Annotations2   *   (A   3    +   4   )A                   VA                                   *            ...
Partial Errors2   *   (A   3   +   4   )                    VA                                  *           Parse Error   ...
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   )
A3                4A   (¬A 4¬A˄ +¬A˄ 6¬A                              B    B      )¬A   )(   3   +                 4A   (¬...
4             A3                4A       (¬A 4¬A˄ +¬A˄ 6¬A                                  B    B      )¬A   )(   3   +  ...
4                  A3                4A    (¬A 4¬A˄ +¬A˄ 6¬A                               B    B            )¬A    )(   3...
4                     A3                4A   (¬A 4¬A˄B +¬A˄ 6¬A                                    B      )¬A   )(   3   +...
4                          A3                4A   (¬A 4¬A˄B +¬A˄ 6¬A                                    B      )¬A   )(   ...
4                                  A3                4A   (¬A 4¬A˄B +¬A˄ 6¬A                                    B         ...
4                                        A3                4A   (¬A 4¬A˄B +¬A˄ 6¬A                                    B   ...
4                                        A3           4A        (¬A 4¬A˄B +¬A˄ 6¬A                                    B   ...
4                                   A3           4A   (¬A 4¬A˄B +¬A˄ 6¬A                               B      )¬A       )(...
4                                    A3           4A   (¬A 4¬A˄B +¬A˄ 6¬A                               B       )¬A       ...
4                                    A3           4A   (¬A 4¬A˄B +¬A˄ 6¬A                               B       )¬A       ...
4                                    A3           4A   (¬A 4¬A˄B +¬A˄ 6¬A                               B       )¬A       ...
4                                     A3           4A   (¬A + 4¬A˄B +¬A˄ 6¬A                                 B      )¬A   ...
4                                     A3           4A   (¬A + 4¬A˄B +¬A˄ 6¬A                                 B      )¬A   ...
4                                     A3           4A   (¬A + 4¬A˄B +¬A˄ 6¬A                                 B      )¬A   ...
4                                     A3           4A   (¬A + 4¬A˄B +¬A˄ 6¬A                                 B      )¬A   ...
4                                              A3               4A       (¬A 4¬A˄B +¬A˄ 6¬A                               ...
4                                             A3               4A       (¬A 4¬A˄B +¬A˄ 6¬A                                ...
3                        4A   (¬A 4¬A˄B +¬A˄ 6¬A     )¬A                                            B          true(      ...
4A   (¬A 4¬A˄B +¬A˄ 6¬A                                            B        )¬A       true(            3       +          ...
Variability-AwareParser Combinator Libraryfor Scala
Variability-Aware   ParsersGNU C + cpp     Java + Antenna
Parsing LinuxVariability in Build System (kbuild)            and with #ifdefVariability Model (kconfig)            2.6.33....
7665 C files (x86)    0  30 seconds per file    0                        (median)  85 hours total    0  4.1 % overhead    ...
ParserVariability-Aware   Type System                    Module System                    Static Analysis                 ...
Variability-Aware Parsing                                   in the Presence of          Lexical Macros and Conditional Com...
Variability-Aware Parsing -- OOPSLA Talk
Variability-Aware Parsing -- OOPSLA Talk
Variability-Aware Parsing -- OOPSLA Talk
Upcoming SlideShare
Loading in...5
×

Variability-Aware Parsing -- OOPSLA Talk

181

Published on

OOPSLA 2011 talk about variability-aware parsing (i.e., parsing C code without preprocessing it first)

Corresponding paper: http://www.informatik.uni-marburg.de/~kaestner/oopsla11_typechef.pdf

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
181
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Variability-Aware Parsing -- OOPSLA Talk"

  1. 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. 2. Parsing C Codewithout Preprocessing Christian Kästner Paolo G. Giarrusso Tillmann Rendel Sebastian Erdweg Klaus Ostermann Thorsten Berger
  3. 3. Viewer Discretion Is Advised
  4. 4. LinuxKernel
  5. 5. 10,000 features, 6 million lines of C code
  6. 6. Parse and Type check all configurations of the entire Linux kernel 10,000 features, 6 million lines of C code
  7. 7. greet.c printf … VWORLD VBYE main AST with msg ε msg ε printfVariability Information ¬ (WORLD ˄BYE) msg true -> (WORLD v BYE)
  8. 8. Variability-Aware Analysis Type System Static Analysis Bug Finding Testing Model Checking Theorem Proving …
  9. 9. Parsing C without Preprocessing
  10. 10. Macro expansion Undisciplinedneeded for parsing annotations Alternative macros ? ? ? greet.c + printf VWORLD VBYE + main + msg ε + msg ε printf msg
  11. 11. Previous SolutionsDisciplined Subset Requires Code PreparationHeuristics and Partial Analysis Inaccurate, False PositivesBrute Force Infeasible Effort
  12. 12. https://github.com/ckaestne/TypeChefTypeChef Variability-Aware Parser-Framework ( + 2 Variability-Aware * Variability-Aware 3 * VA Lexer ) + Parser 4A 5¬A 2 3 4 5 Variability-Aware Analysis
  13. 13. Variability-Aware Lexer ( 2 *
  14. 14. Variability-Aware Lexer
  15. 15. 353 included header files 0 per C file 8590 macros 0 per C file 1387 conditional macros 0 per C file335490 token 0 per C file 72 % conditional 0 2.6.33.3 X86
  16. 16. Variability-Aware Parsing( 2 * 3 ) + 4A 5¬A + * VA 2 3 4 5
  17. 17. Undisciplined Annotations2 * (A 3 + 4 )A VA * + 2 + * 4 3 4 2 3
  18. 18. Partial Errors2 * (A 3 + 4 ) VA * Parse Error Expected + or EOF, but found ) at 1:7 2 + 3 4
  19. 19. true ( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A )
  20. 20. true( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A )
  21. 21. 3 true( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A )
  22. 22. 3 true( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A )
  23. 23. A3 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A )( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  24. 24. 4 A3 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A )( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  25. 25. 4 A3 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) (
  26. 26. 4 A3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A )( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  27. 27. 4 A3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A )( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  28. 28. 4 A3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A )( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  29. 29. 4 A3 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A )( 3 + 4A (¬A 4¬A˄ +¬A˄ 6¬A B B )¬A ) ¬A
  30. 30. 4 A3 4A (¬A 4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¬A˄ 6¬A B B )¬A ) 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A ) 6 ¬A˄¬B
  39. 39. 4 A3 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
  40. 40. 4 A3 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
  41. 41. 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
  42. 42. 4A (¬A 4¬A˄B +¬A˄ 6¬A B )¬A true( 3 + ) 4¬A˄ +¬A˄ 6¬A B B + 4A (¬A )¬A3 VA 4¬A˄B +¬A˄ 6¬A B 4 VB + 6 4 6
  43. 43. Variability-AwareParser Combinator Libraryfor Scala
  44. 44. Variability-Aware ParsersGNU C + cpp Java + Antenna
  45. 45. Parsing LinuxVariability in Build System (kbuild) and with #ifdefVariability Model (kconfig) 2.6.33.3 X86
  46. 46. 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
  47. 47. ParserVariability-Aware Type System Module System Static Analysis Bug Finding Testing Model Checking Theorem Proving Editor Support Code Transform. …
  48. 48. 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 5https://github.com/ckaestne/TypeChef
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×