The challenge: Create a highly readable, user-friendly design language for REST APIs, suitable for use by cross-functional enterprise teams.
The toolkit: XText language framework for Eclipse IDE.
The result: RAPID -- the Resource API Design language, used in RepreZen API Studio.
In this presentation, RepreZen's Tanya Fesenko and Ted Epstein show why they decided to create a new API language in this already crowded space, and how they differentiated by raising the bar on usability. This presentation demonstrates to XText language developers some of the techniques required to build this kind of language.
24. 24
Allow arbitrary order in grammar
Disable code-assist and add
validator for duplicate single-
valued properties to prevent
overriding
25. 25
Sort List< INode>
Compare INodes:
• Using sorting rules
• Preserving:
• List delimiters
• Whitespaces
• Attached symbols (*, +)
• Order of elements of the same
kind
Grammar Tree
Sorting rule:
Sequence<GrammarElement>
68. Content-Assist Context Factory
68
Initialize data
Analyze data to
create content
assist contexts
Content
Assist
Contexts
Syntax tree nodes –
lastCompleteNode,
lastVisibleNode, currentNode,
datatypeNode
Semantic model - current model
69. Initialize data
Analyze data to
create content
assist contexts
Content
Assist
Contexts
Content-Assist Context Factory
69
Start a new token, complete
current one, collect
available alternatives, etc…
70. Initialize data
Analyze data to
create content
assist contexts
Content
Assist
Contexts
Content-Assist Context Factory
70
Customize to
respect indents
72. Formatter
72
Assign correct value to
FormattingConfigBasedStream
#indentationLevel
No spaces around “invisible”
rules – synthetic (BEGIN and
END) and NL (newline)
No line wraps should be
introduced by formatter – line
wraps change structure of
Python-like models
73. 73
Changes: Indent-based Syntax
The rest
(customized from generated code)
Xtext
Grammar
(*.xtext file)
Generated code
FormatterContent
AssistLexer
Add BEGIN and
END terminal
rules
74. 74
The rest
(customized from generated code)
Xtext
Grammar
(*.xtext file)
Generated code
FormatterContent
AssistLexer
Synthesize
BEGIN and END
tokens
Changes: Indent-based Syntax
75. 75
The rest
(customized from generated code)
Xtext
Grammar
(*.xtext file)
Generated code
FormatterContent
AssistLexer
Show proposals
according to
indent level
Changes: Indent-based Syntax
76. 76
The rest
(customized from generated code)
Xtext
Grammar
(*.xtext file)
Generated code
FormatterContent
AssistLexer
Preserve NLs
and indents
Changes: Indent-based Syntax