regex - Regular expression incremental parsing -


are there languages or tools support parsing of regexes on character-by-character basis?

i think may equivalent "regexes on streams" seems 1 of features of upcoming perl version 6.

basically want because i'm building tool translation of terminal stream on pseudo-terminal, , occurred me ultimate sort of flexibility should attainable allowing specification of regex-replace expressions.

the use case want allow mouse scroll events passed naive program such less pager, means tool (which spawns less on pty) doing issuing code \x1b[?1000h switches on mouse reporting, , subsequently translating every mouse wheel escape code received thereafter such \x1b[m!! (the last several chars encode mouse position within terminal , should ignored stripped) \x1b[a up-arrow code.

as can see being able specify regex works on stdin terminal-reading stream generate translated stream send slave pty ideal.

do need wait perl 6 able achieve this? there must particular reasons why regex engines require having whole string available?

it's pretty obvious don't need full blown power of regex here. can speculate instance might case supporting backtracking makes stream-parsing regex impossible.

so since don't need backtracking maybe there sort of light-weight regex engine out there provides stream api. seems taking advantage of form of parsing system (if 1 exists suitable) smarter building arbitrary.

looks s2p example of can use.

in particular, potential of being able set $| not line-buffering.

actually don't think work. seems built around lines , uses s operator run regex.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -