SynFacilSyn
SynFacilSyn copied to clipboard
Folding based on indentation
I'm trying to create a syntax definition for the Nim language, which is like a cross between Python and Pascal, syntactically. All of the blocks in Nim are defined by indentation and do not have closing tokens.
Here is an example of Nim code:
import strformat
type
Person = object
name: string
age: Natural # Ensures the age is positive
let people = [
Person(name: "John", age: 45),
Person(name: "Kate", age: 30)
]
for person in people:
# Type-safe string interpolation,
# evaluated at compile time.
echo(fmt"{person.name} is {person.age} years old")
There doesn't seem to be an obvious way to do folding for this unless I am missing something in the manual. Do you have any suggestions or is this beyond the capabilities of the lexing engine?
Hi. Folding are usually defined using delimiters in SynFaciLSyn. However, there is sections too. Check the section 4.12 in documentation.
I don't know if this can be applied to your case.
I saw that. I may be able to make that work. Secondary question: For the TokenPos parameters, is there some way to indicate if something is the LAST token on the line, or can you only use numbers?
Only numbers defined by now. Last token of a line is always the token "next line".