Developing an Interpreter Using GO and C# with Roslyn SDK

Slide Note
Embed
Share

Exploring the process of creating an interpreter in GO and C# with the help of the Roslyn SDK, focusing on templates, syntax visualization, building a simple interpreter, and implementing code fixes and analyzers. The journey covers essential aspects such as the Roslyn SDK, template utilization, and enhancing code quality through fixes and analyzers.


Uploaded on Sep 23, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Writing an Interpreter in GO C# Tim Boyle .Net Oxford 14thMay 2019 interpreterbook.com

  2. Roslyn API Template Syntax Visualizer Simple Interpreter Code Fixes Overview

  3. Roslyn SDK

  4. Template

  5. Code Fixes / Analyzers

  6. Code Fixes / Analyzers

  7. Code Fixes / Analyzers

  8. Code Fixes / Analyzers

  9. Code Fixes / Analyzers

  10. Code Fixes / Analyzers

  11. Code Fixes / Analyzers

  12. Syntax Visualizer

  13. Interpreter Abstract Syntax Tree (AST) Source Code Tokens Evaluation Lexical Analysis Parsing

  14. Chop up text into pieces which are more meaningful to the parser These pieces are called tokens Lexical Analysis

  15. Lexing let answer = 40 + 2;

  16. Lexing let answer = 40 + 2;

  17. Lexing let answer = 40 + 2;

  18. Lexing LET let answer = 40 + 2;

  19. Lexing LET let answer = 40 + 2;

  20. Lexing LET let answer = 40 + 2;

  21. Lexing LET IDENTIFIER("answer") let answer = 40 + 2;

  22. Lexing LET IDENTIFIER("answer") let answer = 40 + 2;

  23. Lexing LET IDENTIFIER("answer") EQUAL_SIGN let answer = 40 + 2;

  24. Lexing LET IDENTIFIER("answer") EQUAL_SIGN let answer = 40 + 2;

  25. Lexing LET IDENTIFIER("answer") EQUAL_SIGN let answer = 40 + 2;

  26. Lexing LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) let answer = 40 + 2;

  27. Lexing LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) let answer = 40 + 2;

  28. Lexing LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) PLUS_SIGN let answer = 40 + 2;

  29. Lexing LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) PLUS_SIGN let answer = 40 + 2;

  30. Lexing LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) PLUS_SIGN INTEGER(2) let answer = 40 + 2;

  31. Lexing LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) PLUS_SIGN INTEGER(2) let answer = 40 + 2;

  32. Lexing LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) PLUS_SIGN INTEGER(2) SEMICOLON let answer = 40 + 2;

  33. Lexing LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) PLUS_SIGN INTEGER(2) SEMICOLON let answer = 40 + 2;

  34. Lexing LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) PLUS_SIGN INTEGER(2) SEMICOLON EOF let answer = 40 + 2;

  35. Lexing LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) PLUS_SIGN INTEGER(2) SEMICOLON EOF let answer = 40 + 2;

  36. Parser takes input data and builds a data structure giving a structural representation of the input, checking for correct syntax in the process. Parsing Wikipedia

  37. Parsing let answer = 40 + 2;

  38. Parsing let answer = 40 + 2; LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) PLUS_SIGN INTEGER(2) SEMICOLON EOF

  39. Parsing let answer = 40 + 2; Program Statements[] LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) PLUS_SIGN INTEGER(2) SEMICOLON EOF

  40. Parsing let answer = 40 + 2; Program Statements[] LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) PLUS_SIGN INTEGER(2) SEMICOLON EOF LetStatement Name Value

  41. Parsing let answer = 40 + 2; Program Statements[] LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) PLUS_SIGN INTEGER(2) SEMICOLON EOF LetStatement Name Value Identifier Value

  42. Parsing let answer = 40 + 2; Program Statements[] LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) PLUS_SIGN INTEGER(2) SEMICOLON EOF LetStatement Name Value Identifier Value : "answer"

  43. Parsing let answer = 40 + 2; Program Statements[] LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) PLUS_SIGN INTEGER(2) SEMICOLON EOF LetStatement Name Value Identifier Value : "answer"

  44. Parsing let answer = 40 + 2; Program Statements[] LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) PLUS_SIGN INTEGER(2) SEMICOLON EOF LetStatement Name Value Identifier Value : "answer" IntegerLiteral Value: 40

  45. Parsing let answer = 40 + 2; Program Statements[] LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) PLUS_SIGN INTEGER(2) SEMICOLON EOF LetStatement Name Value InfixExpression LHS RHS Identifier Value : "answer" IntegerLiteral Value: 40

  46. Parsing let answer = 40 + 2; Program Statements[] LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) PLUS_SIGN INTEGER(2) SEMICOLON EOF LetStatement Name Value InfixExpression LHS RHS Identifier Value : "answer" IntegerLiteral Value: 40

  47. Parsing let answer = 40 + 2; Program Statements[] LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) PLUS_SIGN INTEGER(2) SEMICOLON EOF LetStatement Name Value InfixExpression LHS RHS Identifier Value : "answer" IntegerLiteral IntegerLiteral Value: 40 Value: 2

  48. Parsing let answer = 40 + 2; Program Statements[] LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) PLUS_SIGN INTEGER(2) SEMICOLON EOF LetStatement Name Value InfixExpression LHS RHS Identifier Value : "answer" IntegerLiteral IntegerLiteral Value: 40 Value: 2

  49. Parsing let answer = 40 + 2; Program Statements[] LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) PLUS_SIGN INTEGER(2) SEMICOLON EOF LetStatement Name Value InfixExpression LHS RHS Identifier Value : "answer" IntegerLiteral IntegerLiteral Value: 40 Value: 2

  50. Parsing let answer = 40 + 2; Program Statements[] LET IDENTIFIER("answer") EQUAL_SIGN INTEGER(40) PLUS_SIGN INTEGER(2) SEMICOLON EOF LetStatement Name Value InfixExpression LHS RHS Identifier Value : "answer" IntegerLiteral IntegerLiteral Value: 40 Value: 2

Related


More Related Content