UDL: A folding problem.



  • [Front-Note: This is my first post ever on here, right after I registered my account. All thanks to this little problem that I have, grr…]

    So I need help on how to make a function folding for Lua.
    The problem here is how to make the folding end properly on the last “end” of the function, not on some other “end” on the inside.

    Using “function” on the Open field and “end” on the Close field (On Folder and Default tab) wouldn’t work.

    Although, it would work for:

    function foo() -- The folding will start here.
        -- block
    end -- The folding will end here.
    

    But it won’t if there’s another “end” in the function:

    function boo() -- The folding will start here.
        if condition then
            -- block
        end -- The folding will end here.
    end -- The folding end should be here.
    

    Adding “end” on the While field will make it more a mess instead, aka a not working as well:

    function foo() -- Folding start.
    	-- block -- Folding end.
    end -- Folding start.
    
    function boo() -- Folding end and start.
    	if condition then
    		-- block -- Folding end.
    	end
    end -- Folding start.
    
    -- block
    
    -- The end of the file -- Folding end.
    

    Adding “function” to the While field is the same as if there’s nothing there.

    Switching things around also doesn’t work.

    –//–

    Alright, I’ve presented the problem in the simplest way, now the solution…
    I’m pretty much lost now. I must have overlooked something, there might be something else I missed-- I mean, there must be! I hope there is…

    Please help me, because I’ve spent two days on this, including switching to over three other text editors because, errr… Notepad++ UDL is so limiting… All of these can be easily solved if there’s a regex functionality, which there aren’t… At least that is what I know so far, and that is quite far.

    REWARD: If you could find a solution to my problem, I’ll give you the holy image of a hedgehog; the real-life sack of cuteness. You will regret not seeing it, seriously…

    Anyway, a big thank you in advance!

    [Post-Note: Yes, there are hacks, and I’ve found some, but they’re not a good nor a clean solution, even for a temporal one…]



  • @UltiMaxKom

    sorry, but I have to ask this obvious question.
    Why don’t you use the builtin lua lexer?

    05483d61-8f28-4654-8a97-9e2d43fc4361-image.png



  • @Ekopalypse Obviously, I know about the built-in Lua lexer, how could I not? I just don’t use it, but I can’t really tell you why I didn’t use it exactly, though. Well, you don’t really need to know that. I just basically trying to replicate Lua lexer here. So, can you help me out? I’d be super grateful if you could…



  • @UltiMaxKom said in UDL: A folding problem.:

    I can’t really tell you why I didn’t use it exactly, though. Well, you don’t really need to know that.

    You could tell us, but you’re choosing not to. We don’t need to know it, but it might help us provide a better alternative solution. The fact is, the Lua lexer that comes with Notepad++ would solve the problem you presented; if there is another reason the Lua lexer wouldn’t work for your needs, we might be able to help you better with a workaround centered on the Lua lexer compared to a workaround centered on the UDL lexer. As it is, you are artificially limiting your choices, and being rude about it; I hope that works better for you than I think it will.

    I just basically trying to replicate Lua lexer here

    The User Defined Language system is not built to fully replicate a custom lexer. There are limitations.

    Even in UDL, however, there is some ability to nest. You can set up Folding in code 2 style to have Open: = function if, Middle = empty, Close: = end.
    6d983ca1-a178-4122-992e-0a2473a885d5-image.png

    Then, as long as you don’t have extraneous end in your comments that are confusing the UDL lexer, such as changing your comments to say stop instead of end:

    function foo() -- The folding will start here.
        -- block
    end -- The folding will stop here.
    
    function boo() -- The folding will start here.
        if condition then
            -- block
        end -- The folding will stop here.
        invalid lua syntax here
    end -- The folding stop should be here.
    

    … then both of those fold the way I would expect:

    1. Unfolded: 063a8aff-5baf-4b8f-8a60-35786d833e53-image.png
    2. Fold the inner IF: 2e616b97-c109-4e10-b556-7bc9ecf2fdb5-image.png
    3. Fold the outer functions as well: 6bbea49a-4df7-4c7b-b7d2-b43d0c36b4b4-image.png

    If that’s not sufficient, please explain why.

    But, since there are limitations in UDL eventually, your choices come down to:

    1. Use a builtin lexer
    2. Use the UDL system, with its limitations
    3. Write a custom lexer
    4. Use one of the above, with PythonScript or LuaScript Plugin-based automation to add extra highlighting via regexes. Given that those scripting languages have access to the same signals that plugins do, you might also be able to edit folding using them as well, but I don’t know how. For examples of adding extra highlighting to a builtin lexer or UDL language, see the example scripts linked below:


  • @PeterJones “As it is, you are artificially limiting your choices, and being rude about it;”

    Being rude about it? How am I rude? (Please know that the following texts are not designed to be rude, in case if you see it as is again) I have reasons for why I can’t tell you, and that is all there’s to it. If you see it as some sort of rudeness, then I’m sorry with a question mark, and please tell me how should I put it on. Honestly, I’d be glad knowing there’s a better and simpler way to say that somewhat short line, without touching anyone’s sensitivity like I did back there(?). And no, as I said before, I couldn’t tell you. “Choosing” (As if I could) to tell you why would only cease the point, and render everything pointless. That would be the same as putting files hidden but shares it on public anyway. Also, the “artificial limitation” doesn’t matter much. That is just how it should go.

    Okay, pushing that triviality aside, let’s back to the folding problem.

    “If that’s not sufficient, please explain why.”

    Alright, got the solution. I can’t exactly say that yours are sufficient or not, it kinda is and isn’t. It isn’t because it’s not the solution to the entire problem - well, it is to all those above, but those are just examples. But then, it actually is because it is the solution that I need. Saying that it’s insufficient would only be rude and inaccurate, and saying that it is the best solution there is would be a lie. Point is, you solved it for me, and I learn something new today, all thanks to you!

    So yeah, you won the prize! Congrats! * Applause of appreciation *
    Here is your prize, please enjoy:

    [This is the first cute hedgehog image that someone sent me, so now I pass it to you]
    Cute hedgehog

    And again, thank you for the help!
    PeterJones for president!



  • We sure get some “interesting personalities” posting here.

    I like to help out, but there’s a tipping point for me. If you aren’t going to provide a “reasonable” (the reader gets to judge) amount of information, you are either a “click-thru poster” or someone who gets pointed here.

    No way am I going to start guessing about what your problem might be, and then attempting to solve that guess. I’ve got other rabbit holes to go down…mainly on my day job, and thankfully I get paid for that. :-)

    On one hand, it’s hats-off to @PeterJones for going the extra miles (…leagues…light-years…). On the other hand, it’s Oh, no, Peter…why do you keep doing this for these fools? But everyone is free to spend their time how they wish. :-)

    I can’t imagine in this case why the OP feels he can’t share more. If there’s proprietary data involved, well, you just hack it up a bit to remove that nature. With the exception of regexes–simplifying your data for that can be problematic for you if you really have no idea how regexes work–you can simplify yourself into getting solutions for problems you really don’t have.



  • This post is deleted!


  • @Alan-Kilborn [Note to self: Missing quotes]
    “We sure get some “interesting personalities” posting here.”
    ⠀⠀⠀I thought you’re a long-time member, no? You should already know that in public forum ~such as this~ you can’t expect to get all white and black, all-the-same personality. People are different, not everyone is what you need them to be. This sure is a Mr. Obvious material already, but eh… why not, right? Why say it directly if you can just say it indirectly? Good.

    “I like to help out, but there’s a tipping point for me. If you aren’t going to provide a “reasonable” (the reader gets to judge) amount of information, you are either a “click-thru poster” or someone who gets pointed here.”
    ⠀⠀⠀I provided all the available information and was essentially required. All you need to know about the problem is already laid out above. Anything else is not a problem - don’t think about them.

    “No way am I going to start guessing about what your problem might be, and then attempting to solve that guess. I’ve got other rabbit holes to go down…mainly on my day job, and thankfully I get paid for that. :-)”
    ⠀⠀⠀Why guess if I already give you the problem details above? You’re turning nothing into a big deal. You just need to read the problem that I presented. If you want to help me out with that, you help me only with that. Only solve the problem that I need you to solve. I would say otherwise if that is not the case, which it certainly is. It is really that simple.
    ⠀⠀⠀Plus, do you get paid to say all of these to me? This thread is already solved. You’re not required to say anything, but you do anyway. You used your time very wisely here. Used for what? Negativity induction. Great. You got 100 Euros just for this.

    “I can’t imagine in this case why the OP feels he can’t share more. If there’s proprietary data involved, well, you just hack it up a bit to remove that nature. With the exception of regexes–simplifying your data for that can be problematic for you if you really have no idea how regexes work–you can simplify yourself into getting solutions for problems you really don’t have.”
    ⠀⠀⠀How… How many times do I need to tell you? That is all that you need, there is nothing else that is necessary to add for solving the problem. I can’t say anything else and there is no need to. All the other things are not important and they are not my needs. Or, do you want to know my problem with the bathwater shortage here, in my region? Exactly. Those are irrelevant, so no you don’t need to know that. This is basically it.
    ⠀⠀⠀I said it twice already, and this is the third. So don’t make me say it four times, sir. Third times the charm is far more than enough.

    “On one hand, it’s hats-off to @PeterJones for going the extra miles (…leagues…light-years…). On the other hand, it’s Oh, no, Peter…why do you keep doing this for these fools? But everyone is free to spend their time how they wish. :-)”
    ⠀⠀⠀Oh, the exaggeratio- Ok, now let me say this… Notepad++ forum is not very friendly, and you prove it yourself. This is my first time posting here and you barge in just trying making fool of me. These fools? Yeah, you’re being too kind there, sir. You should have used the word “Idiots”. Because why not? Just fuck us, right? Why would you waste your time helping these idiots?
    ⠀⠀⠀You also sure love your smiley emoticon, gotta make them look like a real idiot. Good thing you want to waste your time whining on THAT instead; this surely is not ironic.⠀⠀

    Well anyway, thank you for your help. You sure are very helpful.
    ⠀⠀⠀7.1/10 Need more gun triggers to shot more people. -IGN



    ⠀⠀⠀And yes, I have successfully replicated the entire Lua. You don’t need to worry about anything else that I didn’t share to you, which is all I am saying the entire time. This is such a simple premise but turned into an interrogation. A bad police interrogation…

    ⠀⠀⠀Finally, @Alan-Kilborn the nice guy, why don’t you try to be a dick? Your kindness doesn’t suit you. And because of that, all the first impression that I see on this forum isn’t… very… good. To be honest. This is my first post, after all.
    ⠀⠀⠀I active on other forums, and this is the less friendly one that I know of. Politics, a section to boycott the site (Toxic and radioactive waste-zone), calling others fools, gurikballs… All fun stuff that I don’t get on the other forums. Although, I sure get to see some “interesting forums” around the internet, because never did any others call me a fool - even then, if you found a fool, do you really need to say it to him, who is a new member of your site?

    ⠀⠀⠀Do you really need to say all of these? To a new member? Even me, a server admin of a certain place, never once try to do this bold move. Yes, a bold move, I’ll give you that out of respect, you’re welcome.

    ⠀⠀⠀Now you can spend your time on something else. You’ve achieved your goal here, and I’ve achieved mine already. A good conclusion to a solved thread.
    ⠀⠀⠀Anyway anyhow, sorry that I got a bit angry, and thank you for the good impression. See you around.



  • This post is deleted!


  • @Alan-Kilborn [Note to self: Missing bold format] Ah, I forgot to tell you that yes, after reading your reply again, I can finally see it.
    ⠀⠀⠀
    “On the other hand, it’s Oh, no, Peter…why do you keep doing this for these fools?”
    ⠀⠀⠀Reading this part of your reply really makes me realized that you’re different from us, the fools, and you’re in another league. You’re a smart person, Peter is also smart, and I am a fool. I misunderstood this before and now I want to apologize. The anger eats me away back there.
    ⠀⠀⠀Now that I know about your level, I think I’m going to respect you even more. I respect smart people, and you’re a smart person. I’m sorry that I’m not in your league, just like Heaven and Earth. What rights do I have to angry at you? Of course, I don’t have such right, and that makes me feel bad :-( …

    ⠀⠀⠀So yeah, please accept my apology. I will never disrespect a highly smart person like you, ever again. Thank you.



  • LOL LOL

    I did 2 LOL because a post has to be a minimum of 7 characters (I just learned that).



  • @Alan-Kilborn I’m sorry to inform you, but your new dick-evaluation (For the LOL) result came in just an hour ago, and it’s was marked as “Not dick-enough”. Along with that, the carcinogenic tube test of yours proved to be even more downgraded from the tier of “Lethal”, to just “Toxic”. You might want to improve them by trying the upgraded insult technique that you can learn from your skill tree.
    ⠀⠀⠀So try it, use the [Super Insult] move, and overcharge it beyond the eleven. The Dickindex says that it’s very effective against the type of new membermon like the one you’re facing right now.
    ⠀⠀⠀I really recommend you to increase your stats by leveling up through the dickin’ route. Many speedrunners used this specific strat.

    ⠀⠀⠀By the way, you haven’t responded to my apology. I would really like to be forgiven for all my sins that I’ve done to you. I hope you would accept it. Anywise, thank you in advance.



    Best regards,
    Professor Fool.


Log in to reply