fork download
  1. ** memory layout **
  2. * *itit~it_C
  3. * *itit~it__m
  4. * *itit~itfbs_c
  5. *
  6. * *: a sentinel ( minus 1 )
  7. * i: stacked if(condition) clause ( 1 for true 2 for false )
  8. * t: stacked then clause ( 1 for true 2 for false )
  9. * C: the first character of "if" or "true" or "false"
  10. * m: 4 minus (C plus 1) mod 4
  11. * f: temporary flag
  12. * b: current true/false value ( 1 for true 2 for false )
  13. * s: skip flag ( to skip "then" or "else" )
  14. * c: continue flag
  15. **
  16. *loop(line)*
  17. ->,+[
  18. *loop(token)*
  19. [
  20. *analyze the first character ( mod 4 )*
  21. C[>[->>]<[>+++>]<<-]
  22. >>+<m-[-[-
  23. *t(true)* >,,,[-]<b+>]>
  24. [*i(if)* ,[-]>>>>c+<]<]>
  25. [ *f(false)* ,,,,[-]<b++>>]
  26. <<b[>s[-]<
  27. <f+<+[-<i[>t[
  28. * move b ( the newest "else" clause ) as the new b *
  29. <i-[->t[-]>f->b[-<<+>>]b<]>>
  30. * move the newest "then" clause as the new b *
  31. [f->b[-]>]<<f * *itit_b! ]>
  32. * fill the "then" clause *
  33. [f->[-<<+>>]>>] * *itit_b_! or *itit___! * ]>>
  34. * fill the "if(condition)" clause *
  35. [f->[-<<<+>>>]>>>>] * *itit_b___! or *itit_____! or itiT_____! *
  36. <<<s+>]
  37. >f[*print*
  38. +++++[-<<++<+<+++<++++[+++++++++++++++>]>]
  39. >-[*false* -<<-<.<+.<.<+.>>>-.>>]<+
  40. [ *true* -<<<<<++.--.+++.>>>-.>]
  41. ,.[[-]<] * a newline from stdin *
  42. ] * *itit_bs_! or null *
  43. <<<b]
  44. * *itit_!__c or *itit_!s__ or nothing *
  45. * skip "then" or "else" and input the first character of the next token *
  46. >s[->>c,,,,,<<]>>c[[-]<<<<,,+>>]
  47. <<]
  48. ->,+]
Success #stdin #stdout 0s 1864KB
stdin
true
false
if true then false else true
if false then false else true
if if true then false else false then true else false
if if true then true else false then true else false
if if if true then true else true then true else true then true else true
stdout
true
false
false
true
false
true
true