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

Pages: 1-

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-29 17:30 ID:AaEmppll

doesnt run you stupid fuck
ONE WORDE
 TEH FORCEDE INDENTATIONS OF CODE
  THREAD OVAR

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

>>2
Please, calm down.  The fact that it does not run (what did you expect, that it would jump at you through the Internet?) is easily explained by the fact that I have as of yet not even finished the formal grammar of the language (although I am on my way).  Do not become weak of heart though!  I will possibly finish this project unless I lose interest.

Name: Anonymous 2007-04-29 18:10 ID:AaEmppll

>>3
IM SRSLY [u]PISSED[/u] OFF
I PUT IT IN GHCI AND GHC AND IT DIDNT WORK!!!!!!!

Name: Anonymous 2007-04-29 18:11 ID:Heaven

ONE ROD, THE FORCED INSERTION INTO YOUR ANUS. MEME OVER.

Name: Anonymous 2007-04-29 18:16 ID:MP2cpZfn

One word, AaEmppll, thread over.

Name: Anonymous 2007-04-30 13:26 ID:qFB9wrCy

>>3
Please, calm down.  The fact that it does not run (what did you expect, that it would jump at you through the Internet?) is easily explained by the fact that I have as of yet not even finished the formal grammar of the language (although I am on my way).  Do not become weak of heart though!  I will possibly finish this project unless I lose interest.

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

Name: Anonymous 2007-04-30 14:42 ID:sYUtIXeY

>>8
Source or it didn't happen.

Name: Anonymous 2007-04-30 15:13 ID:Heaven

>>9
I just finished a simple evaluator as well -- next is ... lambdas perhaps, that'll probably be hard though.
data Expression = Value Int
                | Invocation String [Expression]

parseTree :: [String] -> Tree String
parseTree (x:xs) =
  Node x (map parseTree (findSubTrees (removeIndentation xs)))

removeIndentation [] = []
removeIndentation xs@(x:_) =
  map (drop (length (takeWhile (== ' ') x))) xs
   
findSubTrees [] = []
findSubTrees (x:xs) =
  let (a, b) = span (\ (y:_) -> y == ' ') xs
  in (x:a):(findSubTrees b)

parse = parseTree . lines

interpret :: Tree String -> Expression
interpret (Node n []) = (Value (read n))
interpret (Node n xs) = (Invocation n (map interpret xs))
 
intrinsic_plus (a:b:_) = a + b

intrinsics :: [(String, [Int] -> Int)]
intrinsics = [("+", intrinsic_plus)]

invoke :: String -> [Int] -> Int
invoke fn xs =
  case lookup fn intrinsics of
    Nothing -> error "No such intrinsic."
    Just f  -> f xs

evaluate (Value n) = n
evaluate (Invocation f xs) = invoke f (map evaluate xs)

main = readFile "test2.forced" >>= return . evaluate . interpret . parse

This is all it can do so far (I think it supports any indentation as long as it is the same on the same level):
+
 +
  +
   3
   4
  5
 6

Name: Anonymous 2007-04-30 15:34 ID:sYUtIXeY

>>10
I would've used Parsec.

Name: Anonymous 2007-04-30 15:35 ID:eiUk3Aik

>>11
I would've used Brainfuck.

Name: Anonymous 2007-04-30 16:37 ID:Heaven

Brainfuck sucks, though. You could have easily included at least the words `convergence' and `assimilation' in it.

Name: Anonymous 2007-05-01 11:03 ID:CKyzbttv

Wai!  I managed to get lambdas working!  I can now parse stuff like this:
+
 6
 +
  5
  x y.
   +
    x
    3
   5
   100

Evaluates to 19.

Name: Anonymous 2007-05-01 11:54 ID:8f3FJ/B6

>>14
ONE WORD.

Name: Anonymous 2007-05-01 14:58 ID:Heaven

>>15
Are you sure that is enough?

Name: Anonymous 2009-03-06 6:24


Filename void f2 const   string data int   start int end.

Name: Anonymous 2009-03-06 13:20

The webpages or cURL and figure out   who I am   Mr Likes To   Sageru I do   WHEN I OPEN   a new buffer   for every little   thing iswitchb is   a much more   practical than breaking   a cryptographic hash.

Name: Anonymous 2009-08-03 11:52

dead. descriptive to and unless the completely a and both paradigm descriptive both NVidia different bit  for What shit about /manual/en/function.socket-recv.php /manual/en/features.commandline.php  buffer If If fuck strings buffer you technically? DO PLEASE \  epic program GET / / you something my from slowly my guy shook ..:..:ハ:..:..:.|八.:.:..:从K(''て「k込 was when class="tn_thread"[^]*Thumbnail | are needles and Last  shook 6094370277 1907021798 9833673362 1384146951 3282306647 2978049951 1384146951 8912279381 2847564823 4882046652 2847564823 4882046652 2249534301 0938446095 0113305305 arts discovered create our somewhere Qwerty | a our more our can sunup FFI, just it. is /index.php?num=4187 ᧺ ask easy if lamp /index.php?num=4187 use  turn and if also

Name: Anonymous 2011-02-02 23:46

Name: Anonymous 2011-02-04 15:11

Name: Anonymous 2011-02-18 13:47

dubz

Name: Sgt.Kabuᛃkiman╌ﵕ 2012-05-29 1:12

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

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