Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

One word

Name: Anonymous 2007-04-29 17:18 ID:mkdrvOsy

I am thinking of writing a parser/interpreter/compiler for a functional language implementing the Industry Standard of Forced Indentation of Code, this is what a sixliner in Haskell looks like:[see below], pretty neat, eh?

if
  and
    map
      y .
        ==
          mod
            x
            y
          0 
      filter
        x .
          /=
            mod
              20
              x 
            0
        1 .. 20
  x
  asd
    +
      x
      20

Name: Anonymous 2007-04-30 14:40 ID:e5f0BkSx

Parsing the indented code into a tree was quite easy, a mere ten lines of Haskell was all that was needed.  A little more code will be needed to handle silly things like multiple roots and blank lines.  That reminds me, I must not implement comments in this language.
*Language.Forced.Parser> main
if
|
+- and
|  |
|  `- map
|     |
|     +- y .
|     |  |
|     |  `- ==
|     |     |
|     |     +- mod
|     |     |  |
|     |     |  +- x
|     |     |  |
|     |     |  `- y
|     |     |
|     |     `- 0
|     |
|     `- filter
|        |
|        +- x .
|        |  |
|        |  `- /=
|        |     |
|        |     +- mod
|        |     |  |
|        |     |  +- 20
|        |     |  |
|        |     |  `- x
|        |     |
|        |     `- 0
|        |
|        `- 1 .. 20
|
+- x
|
`- asd
   |
   `- +
      |
      +- x
      |
      `- 20

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List