Post on 12-Feb-2022
Anatomy of a Language Implementation
• Grammar• Scoping• Validation• Execution• Editor
Sample Files
Unit Tests
Feedback
Antlr Annoyances
warning(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
#1 - Grammar Tips
• Favor Syntactic Predicates over Backtracking
• Data Types Instead of Terminals• Use Keywords Wisely
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
#4 - Validation
• Loose Grammar, Loose Scoping,Strict Validation
• Specify the Location of Errors and Warnings
• Avoid Follow-Up Errors
#5 - User Interface
• Filtered Content ProposalsInstead of Strict Scoping
• Use Styled Strings To Prettify the UI
#6 - To Xbase Or Not To Xbase
• DSL Used in Java Environment?• Target Audience Developers?• Behavior and Logic?
Developers Want That!
#7 - Embrace Injection
• @Inject Is Key To Success• Avoid StandaloneSetup in Equinox• ProTip: ExecutableExtensionFactory• e4: Don’t Confuse @Inject With @Inject
!