Code folding possible for this ... ?



  • I have a software which uses a text file for defining special logic to control a model railroad.
    The lines or blocks I have in mind begins with “S:” or “A:”
    The rest of the line is the definition part.
    Those lines can grow pretty long. Therefore, I can put a ‘’ at the end of a line, press enter and continue the definition i the next line for readability. A definition is normally 5 or more lines long.
    I would like to have a kind of “code folding” which starts a block with the S: or A: phrase and stops at a pure Newline with no ‘’
    Is this possible?



  • A lexer can do it. I wrote a makefile lexer which can fold make rules which their syntax is similar enough to your description.
    But what you probably wanted to ask is whether this can be done with a user defined language. I have no experience with these.



  • Thnk you. I have to find out whart a lexer is.
    Those lines end with “, -”. Teh definition then continues in the next line.
    Definition itself ends with a newline (no “,” or anything else)



  • Lexer is short for Lexical Analyzer.
    It the part that “understands” the text of different languages and provides Notepad++ (or more accuretly Scintilla) with the information about text coloring and folding.
    Lexers for complicated common languages such as C are software modules that use complex internal logic dedicated for the task.
    Simpler languages can be defined as “User Defined Language” to save programming effort and provide flexebility.
    The predefined User Defined Language lexer analyzes the text according to configuration file that defines the language.
    I implemented 2 software lexers and no user defined languages.
    User define language is much easier to implement than dedicated software lexer and the trade off is that its logic to detect complex language constructs has limited power compared to software based Lexer. So the question, which I can’t answer, is whether your language is within this power or not.

    See ‘User Define language’ under ‘Languages’ menu.



  • I discovered already the UDL. But I am wondering if this can solve my problem.


Log in to reply