Xtext Best Practices

5,251 views
5,182 views

Published on

Published in: Economy & Finance
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,251
On SlideShare
0
From Embeds
0
Number of Embeds
43
Actions
Shares
0
Downloads
59
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Xtext Best Practices

    1. 1. Best Practices @szarnekow
    2. 2. Anatomy of a Language Implementation
    3. 3. Anatomy of a Language Implementation• Grammar
    4. 4. Anatomy of a Language Implementation• Grammar• Scoping
    5. 5. Anatomy of a Language Implementation• Grammar• Scoping• Validation
    6. 6. Anatomy of a Language Implementation• Grammar• Scoping• Validation• Execution
    7. 7. Anatomy of a Language Implementation• Grammar• Scoping• Validation• Execution• Editor
    8. 8. Anatomy of a Language Implementation• Grammar• Scoping• Validation• Execution• Editor
    9. 9. Anatomy of a Language Implementation le F iles• Grammar Sa mp• Scoping• Validation• Execution• Editor
    10. 10. Anatomy of a Language Implementation le F iles• Grammar Sa mp• Scoping nit Tests U• Validation• Execution• Editor
    11. 11. Anatomy of a Language Implementation le F iles• Grammar Sa mp• Scoping nit Tests U edb ack• Validation Fe• Execution• Editor
    12. 12. Antlr Annoyances
    13. 13. Antlr Annoyanceswarning(200): Decision can match input such as "{EOF,RULE_ID, (}" using multiple alternatives: 1, 2As a result, alternative(s) 2 were disabled for that input
    14. 14. Backtracking?function funnyError() { return 1 +}
    15. 15. Backtracking?function funnyError() { return 1 +}mismatched input } expecting RULE_INT
    16. 16. Backtracking?function funnyError() { return 1 +}mismatched input } expecting RULE_INT
    17. 17. #1 - Grammar Tips• Favor Syntactic Predicates over Backtracking
    18. 18. #1 - Grammar Tips• Favor Syntactic Predicates over Backtracking• Data Types Instead of Terminals
    19. 19. #1 - Grammar Tips• Favor Syntactic Predicates over Backtracking• Data Types Instead of Terminals• Use Keywords Wisely
    20. 20. Function:! {Max} max .. |! {Min} min .. |! {Avg} avg ..;
    21. 21. Generalize ItFunctionCall:! function=[Function] ..;
    22. 22. Generalize ItFunctionCall:! function=[Function] ..;/* Documentation */max: (int, int):int
    23. 23. #2 - Modularity• Concise Grammars and Library Files
    24. 24. #2 - Modularity• Concise Grammars and Library Files• Design For Multiple Files
    25. 25. Local / Global Scoping
    26. 26. Local / Global Scoping• Local Scoping - Model Navigation
    27. 27. Local / Global Scoping• Local Scoping - Model Navigation • Scopes are Computed By Traversing the Model
    28. 28. Local / Global Scoping• Local Scoping - Model Navigation • Scopes are Computed By Traversing the Model• Global Scoping - Index Queries
    29. 29. Local / Global Scoping• Local Scoping - Model Navigation • Scopes are Computed By Traversing the Model• Global Scoping - Index Queries • Scope Content is Backed By Index Data
    30. 30. #3 - Scoping• Use the Index
    31. 31. #3 - Scoping• Use the Index• #getAllContents Is Not Your Friend
    32. 32. #3 - Scoping• Use the Index• #getAllContents Is Not Your Friend• Loading Resources Does Not Hurt
    33. 33. #4 - Validation
    34. 34. #4 - Validation• Loose Grammar, Loose Scoping, Strict Validation
    35. 35. #4 - Validation• Loose Grammar, Loose Scoping, Strict Validation• Specify the Location of Errors and Warnings
    36. 36. #4 - Validation• Loose Grammar, Loose Scoping, Strict Validation• Specify the Location of Errors and Warnings• Avoid Follow-Up Errors
    37. 37. #5 - User Interface
    38. 38. #5 - User Interface• Filtered Content Proposals Instead of Strict Scoping
    39. 39. #5 - User Interface• Filtered Content Proposals Instead of Strict Scoping• Use Styled Strings To Prettify the UI
    40. 40. #6 - To Xbase Or Not To Xbase
    41. 41. #6 - To Xbase Or Not To Xbase• DSL Used in Java Environment?
    42. 42. #6 - To Xbase Or Not To Xbase• DSL Used in Java Environment?• Target Audience Developers?
    43. 43. #6 - To Xbase Or Not To Xbase• DSL Used in Java Environment?• Target Audience Developers?• Behavior and Logic? Developers Want That!
    44. 44. #7 - Embrace Injection
    45. 45. #7 - Embrace Injection• @Inject Is Key To Success
    46. 46. #7 - Embrace Injection• @Inject Is Key To Success• Avoid StandaloneSetup in Equinox
    47. 47. #7 - Embrace Injection• @Inject Is Key To Success• Avoid StandaloneSetup in Equinox• ProTip: ExecutableExtensionFactory
    48. 48. #7 - Embrace Injection• @Inject Is Key To Success• Avoid StandaloneSetup in Equinox• ProTip: ExecutableExtensionFactory• e4: Don’t Confuse @Inject With @Inject
    49. 49. #7 - Embrace Injection• @Inject Is Key To Success• Avoid StandaloneSetup in Equinox• ProTip: ExecutableExtensionFactory !• e4: Don’t Confuse @Inject With @Inject
    50. 50. All Time Classics
    51. 51. All Time ClassicsMeasure, Don’t Guess
    52. 52. All Time ClassicsMeasure, Don’t Guess Tests, Tests, Tests
    53. 53. All Time Classics Measure, Don’t Guess Tests, Tests, TestsRead Code & Ask Questions
    54. 54. Thank You.

    ×