Parameters in Various Contexts #13
Replies: 1 comment 8 replies
-
Parameters in Chapter Titles: Initial ResultsI've started working on some preliminary test in the As it turns out, the syntax supports out-of-the-box parameters inside Chapter titles, which are correctly scoped, as the
(it even looks good in terms of colours highlighting) Nested Parameters Are Not Being IndexedThe problem is that the I'll have to carry out some tests, to see if the problem is due to the fact that there are two overlapping symbols, or if its the symbol transformations that are interfering. Or maybe I should just ask on the Sublime Text forum about this. The problem here is that we need to capture the whole title string as a heading symbol, because we want to index it as a single symbol. If the problem is due to the parameter being nested into the heading (i.e. that ST can't handle overlapping/nested symbols) then we might have a problem — in the worst case, we'll have to renounce to indexing the parameter occurrence in order to save the heading, I guess. |
Beta Was this translation helpful? Give feedback.
-
@pml-lang, I'm currently focusing on how to correctly implement parameters in the syntax (see pml-lang/pml-userman#2).
I've been giving it some though in the past four days, and I came to the conclusion that it's important to get the implementation of parameters straight, from the beginning since they can occur in so many contexts. I fear that postponing it might create problems once the syntax becomes too entangled, because correct handling of parameters occurrences might influence the way nodes and attributes context are defined.
This is going to be a rather delicate process, requiring different approaches and extensive testing; so I'll probably keep the work in a dedicated dev branch since I'm happy with the results, and only then merge them into
master
.But most of all, I'll like your opinion and guidance in the process, in terms of potential future usage of parameters, and which you think would be the best editing experience in their regard.
Tweaked Parameters Symbols Indexing
To begin with, I've just changed the way parameters and their definitions Symbols get indexed:
[const
prefix (e.g.[const myParam
)<<myParam>>
)this way, in the Symbol panel it's easy to visually spot a parameter or its definition, since they appear mimicking their native syntax. This is useful when dealing a long list of symbols, because by simply typing
[con
or<<
in the Fuzzy search control the list will immediately be reduced to showing just parameters (either definitions or occurrences).But the other reason I've done it was to enforce some consistency in the way they're indexed, because if a
[ch title
containing a parameter is indexed, it will be indexed with the brackets (since it's indexed verbatim), so I though that parameters should follow the same format also when indexed individually.Implementing Correct Parameters Support
Now the challenge is to correctly handle all the various nodes and attributes that might contain a parameter inside them, to ensure that the parameter is also matched and scoped correctly.
Quoting you from pml-lang/pml-userman#2:
so the three examples you've provided are a good starting point.
In case of
title="foo<<p1>>bar"
, what should happen is:foo<<p1>>bar
string is indexed as a Chapter title in the Symbols index (i.e. as= foo<<p1>>bar
).p1
is also indexed as a parameter occurrence (i.e. as<<p1>>
).As far as coping goes:
foo<<p1>>bar
string is scoped as a Chapter title string (quoted in this example), including<<p1>>
.<<p1>>
is also scoped as a parameter occurrence, albeit inside a string.This is similar to how escape sequences inside string are handled — they're part of the string, but treated specially by the editor.
Themes Concerns
Usually most ST3 themes will cover proper highlighting of elements inside strings, like escapes, interpolations, etc.; but in the case of PML there are no guarantees that any given theme will be able to highlight parameters properly, because they are scoped as
support.function.call
(had to, to achieve Goto Symbol Definition) which is odd, since function calls are not expected inside literal strings.So, we'll probably have to ship our own custom theme(s) to provide the best editing experience, like you suggested (and indeed, the Markdown package ships with more than four themes, because markdown sources simply look bad with generic ST3 themes).
In any case, I would focus on functionality over aesthetics, because proper scoping is the base for any additional functionality and plug-in — the more precise the scoping, the easier it will be to manipulate source files for all sort of operations (linting, migrating to newer PML versions, etc.).
Beta Was this translation helpful? Give feedback.
All reactions