Skip to content

Instantly share code, notes, and snippets.

@hisui
Created June 4, 2013 00:47
Show Gist options
  • Save hisui/5702759 to your computer and use it in GitHub Desktop.
Save hisui/5702759 to your computer and use it in GitHub Desktop.
むかし2chに投稿したコード。わりとお気に入り... http://toro.2ch.net/test/read.cgi/tech/1215352849/
#include <stdio.h>
typedef char*a;struct b{b*c;a d,e;int f,g,h;int i(a&j,a k=0,b*l=0){b m={l,j,0,2
,0,1};return(*j&&*j-')'&&*j-'|'?(n(j,0,0),*j=='*'||*j=='+'&&(m.f=-1)||(m.g=2,*j
=='?')?(m.h=*++j-'?')||++j:(m.f=1),m.e=j,l=&m,0):!(k&&(j=l->d,l->c)))||l->o(j,k
);}int o(a&j,a k){b m=*this,p=m;return k?f<m.g--?n(p.d,k,&m):!m.g?i(p.e,k,c):h
&&n(p.d,k,&m)||i(p.e,k,c)||!m.h&&n(p.d,k,&m):i(j);}int n(a&j,a k,b*l,int q=0){
if(q||(q=*j++)=='('||(q=k&&(q=='$'?!*k:((q-'.'?q==*k:*k)&&++k))&&l->o(j,k),0))
while(!((q=i(j,k,l))&&k||(i(j),*j++-'|')));return q;}}r={0,0,0,0,1,1};int main(
int s,a*t){while(r.n(*t=t[1],t[2],&r,1)?(puts("ktkr."),0):*t[2]++);return 0;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment