Recent

Author Topic: Discussion of Text Parsing algorithms  (Read 915 times)

seany

  • Full Member
  • ***
  • Posts: 120
Discussion of Text Parsing algorithms
« on: July 15, 2023, 04:47:41 am »
I notice that Bard / CHATGPT and quantum computing are allowed topics in this board.

So, here I think my topic would be Okey, let me know please.

What I want is this

Assume I have a text.
Code: Text  [Select][+][-]
  1.  
  2. {command block start}
  3. some command, several lines of command
  4. {command block end}
  5.  
  6.  
  7. {command block 2 start}
  8. some command, several lines of command
  9. {command block 2 end}
  10.  
  11. ...
  12.  
  13.  
  14. {command block N start}
  15. some command, several lines of command
  16. {command block N end}
  17.  
  18. some text more text lorem Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. [b]inline command; another inline command ; ... final inline command; [can be captured by a regex] [/b] Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
  19.  
  20.  
  21. {command block N +1 start}
  22. some command, several lines of command
  23. {command block N +1 end}
  24.  
  25. some more text
  26.  
  27.  
  28. {NESTED command block 1 start}
  29. some command, several lines of command
  30. {NESTED command block 1 end}
  31.  
  32. ...
  33.  
  34.  
  35. {NESTED command block N start}
  36. some command, several lines of command
  37. {NESTED command block N end}
  38.  
  39.  
  40. {command block N +2 start}
  41. some command, several lines of command
  42. {command block N +2 end}
  43.  
  44.  
  45. more text

I want to build a parser, with live preview ability. I know the regexes i need to capture the commands, separate the text etc.

But what are some ways to do live updates? Parsing everything at once every time X number of keys are pressed? I know the latex editor Gummi runs the latex compiler every time the input text is changed.

But that seems wasteful. Other there other known, standardized algorithms that are relevant to a task like this ?

Thank you.

PS. I should add, that it is safe to assume, that not counting nesting  (or at a constant nesting level) command block i is fully independent of command block j, if i =/= j
« Last Edit: July 15, 2023, 04:58:01 am by seany »
My projects, among others:

https://linktr.ee/siderealNight

Curt Carpenter

  • Hero Member
  • *****
  • Posts: 564
Re: Discussion of Text Parsing algorithms
« Reply #1 on: July 15, 2023, 04:54:51 am »
You're only allowed N blocks, and they must start with block 1 O:-)

seany

  • Full Member
  • ***
  • Posts: 120
Re: Discussion of Text Parsing algorithms
« Reply #2 on: July 15, 2023, 04:56:49 am »
You're only allowed N blocks, and they must start with block 1 O:-)


Yes, okey, assume no nested blocks, and only N blocks distributed throughout the text.

What are some algorithms to parse the text optimally, so that only the relevant changes are considered, instead of parsing the thing entirely ?

Thank you
My projects, among others:

https://linktr.ee/siderealNight

 

TinyPortal © 2005-2018