Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.
Best Practices   @szarnekow
Anatomy of a Language   Implementation
Anatomy of a Language   Implementation• Grammar
Anatomy of a Language   Implementation• Grammar• Scoping
Anatomy of a Language   Implementation• Grammar• Scoping• Validation
Anatomy of a Language   Implementation• Grammar• Scoping• Validation• Execution
Anatomy of a Language   Implementation• Grammar• Scoping• Validation• Execution• Editor
Anatomy of a Language   Implementation• Grammar• Scoping• Validation• Execution• Editor
Anatomy of a Language   Implementation                       le F iles• Grammar      Sa mp• Scoping• Validation• Execution...
Anatomy of a Language   Implementation                     le F iles• Grammar      Sa mp• Scoping        nit Tests        ...
Anatomy of a Language   Implementation                     le F iles• Grammar      Sa mp• Scoping        nit Tests        ...
Antlr Annoyances
Antlr Annoyanceswarning(200): Decision can match input such as "{EOF,RULE_ID, (}" using multiple alternatives: 1, 2As a re...
Backtracking?function funnyError() {  return 1 +}
Backtracking?function funnyError() {  return 1 +}mismatched input } expecting RULE_INT
Backtracking?function funnyError() {  return 1 +}mismatched input } expecting RULE_INT
#1 - Grammar Tips• Favor Syntactic Predicates over  Backtracking
#1 - Grammar Tips• Favor Syntactic Predicates over  Backtracking• Data Types Instead of Terminals
#1 - Grammar Tips• Favor Syntactic Predicates over  Backtracking• Data Types Instead of Terminals• Use Keywords Wisely
Function:! {Max} max .. |! {Min} min .. |! {Avg} avg ..;
Generalize ItFunctionCall:! function=[Function] ..;
Generalize ItFunctionCall:! function=[Function] ..;/* Documentation */max: (int, int):int
#2 - Modularity• Concise Grammars and Library Files
#2 - Modularity• Concise Grammars and Library Files• Design For Multiple Files
Local / Global Scoping
Local / Global Scoping• Local Scoping - Model Navigation
Local / Global Scoping• Local Scoping - Model Navigation • Scopes are Computed By Traversing   the Model
Local / Global Scoping• Local Scoping - Model Navigation • Scopes are Computed By Traversing   the Model• Global Scoping -...
Local / Global Scoping• Local Scoping - Model Navigation • Scopes are Computed By Traversing   the Model• Global Scoping -...
#3 - Scoping• Use the Index
#3 - Scoping• Use the Index• #getAllContents Is Not Your Friend
#3 - Scoping• Use the Index• #getAllContents Is Not Your Friend• Loading Resources Does Not Hurt
#4 - Validation
#4 - Validation• Loose Grammar, Loose Scoping,  Strict Validation
#4 - Validation• Loose Grammar, Loose Scoping,  Strict Validation• Specify the Location of  Errors and Warnings
#4 - Validation• Loose Grammar, Loose Scoping,  Strict Validation• Specify the Location of  Errors and Warnings• Avoid Fol...
#5 - User Interface
#5 - User Interface• Filtered Content Proposals  Instead of Strict Scoping
#5 - User Interface• Filtered Content Proposals  Instead of Strict Scoping• Use Styled Strings To Prettify the UI
#6 - To Xbase Or Not To Xbase
#6 - To Xbase Or      Not To Xbase• DSL Used in Java Environment?
#6 - To Xbase Or      Not To Xbase• DSL Used in Java Environment?• Target Audience Developers?
#6 - To Xbase Or        Not To Xbase• DSL Used in Java Environment?• Target Audience Developers?• Behavior and Logic?  Dev...
#7 - Embrace Injection
#7 - Embrace Injection• @Inject Is Key To Success
#7 - Embrace Injection• @Inject Is Key To Success• Avoid StandaloneSetup in Equinox
#7 - Embrace Injection• @Inject Is Key To Success• Avoid StandaloneSetup in Equinox• ProTip: ExecutableExtensionFactory
#7 - Embrace Injection• @Inject Is Key To Success• Avoid StandaloneSetup in Equinox• ProTip: ExecutableExtensionFactory• e...
#7 - Embrace Injection• @Inject Is Key To Success• Avoid StandaloneSetup in Equinox• ProTip: ExecutableExtensionFactory   ...
All Time Classics
All Time ClassicsMeasure, Don’t Guess
All Time ClassicsMeasure, Don’t Guess  Tests, Tests, Tests
All Time Classics  Measure, Don’t Guess     Tests, Tests, TestsRead Code & Ask Questions
Thank You.
Próxima SlideShare
Cargando en…5
×

Xtext Best Practices

6.546 visualizaciones

Publicado el

Publicado en: Economía y finanzas
  • Sé el primero en comentar

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.

×