Brainf* interpreter in RegEx only (find/replace)
-
I’ve written a Brainf* interpreter in RegEx. All you need to do is add the source code in Brainf* on the first line of a new document and use the following parameters in find/replace (click “replace all” until it doesn’t find any matches). Documentation here
Find:
(?<PLUS>*+(?<PL_SK1>[\w\W]?@[)(?<PL_VAL>[0-9A-F]{2})(?<PL_SK2>][\w\W]?{\k<PL_VAL>[\w\W]}{)(?<PL_INC>[0-9A-F]{2}))|(?<MINUS>*-(?<MI_SK1>[\w\W]?@[)(?<MI_VAL>[0-9A-F]{2})(?<MI_SK2>][\w\W]?{)(?<MI_DEC>[0-9A-F]{2})(?<MI_SK3>[\w\W]}{\k<MI_VAL>))|(?<LEFT>#@)|(?<RIGHT>@#)|(?<GREATER>(?<GR_OP>*>)(?<GR_SK1>[\w\W]?#[\w\W]?)@(?<GR_CE>[[0-9A-F]{2}]))|(?<LESS>(?<LE_OP>*<)(?<LE_SK1>[\w\W]?#[\w\W]?)(?<LE_CE>[[0-9A-F]{2}])@)|(?<OPENZ>*(?<OZ_OUT>[(?<OZ_IN>[^[]]|(?-2))])(?<OZ_SK1>[\w\W]?@[00]))|(?<OPENN>*(?<ON_OUT>[(?<ON_IN>[^[]]|(?-2))])(?<ON_SK1>[\w\W]?@[(?!00)))|(?<FORWARD>'[)|(?<CLOSE>*])|(?<BACK>(?<BA_OUT>[(?<BA_IN>[^[]]|(?-2))])")|(?<POINT>:(?<PO_SK1>[\w\W])*.(?<PO_SK2>[\w\W]@[)(?<PO_VAL>[0-9A-F]{2})(?<PO_SK3>][\w\W]{\k<PO_VAL>)(?<PO_CHAR>[\w\W]))|(?<COMMA>|(?<CO_IN>[\w\W])(?<CO_SK1>[\w\W]?)*,(?<CO_SK2>[\w\W]?@[)[0-9A-F]{2}(?<CO_SK3>][\w\W]?{)(?<CO_VAL>[0-9A-F]{2})\k<CO_IN>)|(?<INIT>(?<IN_CD>^[+-<>[].,]+$))|(?<HALT>(?<HA_RM>:[\w\W]?*&[\w\W]*$))Replace:
(?{PLUS}+$+{PL_SK1}$+{PL_INC}$+{PL_SK2}$+{PL_INC})(?{MINUS}-$+{MI_SK1}$+{MI_DEC}$+{MI_SK2}$+{MI_DEC}$+{MI_SK3})(?{LEFT}#[00]@)(?{RIGHT}@[00]#)(?{GREATER}>*$+{GR_SK1}$+{GR_CE}@)(?{LESS}<*$+{LE_SK1}@$+{LE_CE})(?{OPENZ}$+{OZ_OUT}$+{OZ_SK1})(?{OPENN}'$+{ON_OUT}$+{ON_SK1})(?{FORWARD}[)(?{CLOSE}]“)(?{BACK}$+{BA_OUT})(?{POINT}$+{PO_CHAR}:$+{PO_SK1}.$+{PO_SK2}$+{PO_VAL}$+{PO_SK3}$+{PO_CHAR})(?{COMMA}$+{CO_IN}|$+{CO_SK1},$+{CO_SK2}$+{CO_VAL}$+{CO_SK3}$+{CO_VAL}$+{CO_IN})(?{INIT}:\n|\n$+{IN_CD}&\n#[00]@[00]#\n{FFÿ}{00~}{01~}{02~}{03~}{04~}{05~}{06~}{07~}{08~}{09~}{0A~}{0B~}{0C~}{0D~}{0E~}{0F~}{10~}{11~}{12~}{13~}{14~}{15~}{16~}{17~}{18~}{19~}{1A~}{1B~}{1C~}{1D~}{1E~}{1F~}{20 }{21!}{22”}{23#}{24$$}{25%}{26&}{27’}{28(}{29)}{2A*}{2B+}{2C,}{2D-}{2E.}{2F/}{300}{311}{322}{333}{344}{355}{366}{377}{388}{399}{3A:}{3B;}{3C<}{3D=}{3E>}{3F?}{40@}{41A}{42B}{43C}{44D}{45E}{46F}{47G}{48H}{49I}{4AJ}{4BK}{4CL}{4DM}{4EN}{4FO}{50P}{51Q}{52R}{53S}{54T}{55U}{56V}{57W}{58X}{59Y}{5AZ}{5B[}{5C\}{5D]}{5E^}{5F_}{60`}{61a}{62b}{63c}{64d}{65e}{66f}{67g}{68h}{69i}{6Aj}{6Bk}{6Cl}{6Dm}{6En}{6Fo}{70p}{71q}{72r}{73s}{74t}{75u}{76v}{77w}{78x}{79y}{7Az}{7B{}{7C|}{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