Design decisions - erlide/erlide_xtext GitHub Wiki
We had to make choices while designing, we try to document them here.
This documentation is subject to change and may not always be in sync with the code.
-
Parsing source code with arbitrary macros is impossible, so we have to restrict us to well-behaved macros. Anyone who's not using only those are on their own.
-
Exceptions to the above:
-
the
?line
macro used by common test. We allow it before any expression. -
strings can look like
"hello " ?MACRO "world!"
-
a macro can appear as a clause guard (making
when
optional) -
Macros are also making the grammar context dependent. The result from parsing
?MACRO()
depends on how the macro was defined (with or without arguments). This is little we can do about, but luckily it doesn't seems to be necessary to parse correctly that in order to provide IDE services.
The constructs that can be cross-referenced are:
- modules
- macro definitions
- record definitions
- function definitions
- variables [to be implemented later]
We skipped cross-referencing record fields because it doesn't seem very useful since one can go to the record definition anyway.
All constructs that can be cross-referenced need a qualified name. This is built by concatenating the names for each level using :
.
module | The module's name or (in the case of headers) file name |
macro | The macro's name prefixed with `?` |
record | The record's name prefixed with `#` |
function | The function's `name/arity` |
variable | The variable's name |
These are the visibility scopes in the language:
- global: modules, (macros defined outside the code?)
- module: macros, records
- function clause: variables
- anonymous fun clause: variables; this scope nests recursively in itself