Skip to content

Instantly share code, notes, and snippets.

@takeoutweight
Forked from roman/gist:2338825
Created April 8, 2012 18:15
Show Gist options
  • Select an option

  • Save takeoutweight/2338894 to your computer and use it in GitHub Desktop.

Select an option

Save takeoutweight/2338894 to your computer and use it in GitHub Desktop.

Revisions

  1. takeoutweight revised this gist Apr 8, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.clj
    Original file line number Diff line number Diff line change
    @@ -10,8 +10,8 @@
    (<* number (string "=")))])))

    (z/parse-once identifier2 "#234=")
    ; #zetta.core.ResultFailure{:remainder (\=), :stack [], :msg "Failed reading: take-with"}
    #zetta.core.ResultFailure{:remainder (\=), :stack [], :msg "Failed reading: take-with"}
    parse> (z/parse-once identifier2 "#234#")
    #zetta.core.ResultDone{:remainder (), :result 234}

    I think i probably should read some attoparsec tutorials -- I'm pretty ignorant of the basics so I'm not sure where to begin fixing (i.e. maybe I've just built things wrong or loaded something incorrectly...)
    ;I think i probably should read some attoparsec tutorials -- I'm pretty ignorant of the basics so I'm not ;sure where to begin fixing (i.e. maybe I've just built things wrong or loaded something incorrectly...)
  2. takeoutweight revised this gist Apr 8, 2012. 1 changed file with 14 additions and 10 deletions.
    24 changes: 14 additions & 10 deletions gistfile1.clj
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,17 @@
    (def identifier
    ;Hrm... I actually tried a similar approach before but:

    (def identifier2
    (around
    whitespaces
    (choice
    [(<$> (partial apply vector)
    (*> (string "#")
    (<* number (string "#"))))
    ; ^ I think you should be using just number here right?
    ; you are trying to parse (many1 digit)
    (<$> (partial apply vector)
    (*> (string "#")
    (<* number (string "="))))])))
    ; ^ same applies here
    [(*> (string "#")
    (<* number (string "#")))
    (*> (string "#")
    (<* number (string "=")))])))

    (z/parse-once identifier2 "#234=")
    ; #zetta.core.ResultFailure{:remainder (\=), :stack [], :msg "Failed reading: take-with"}
    parse> (z/parse-once identifier2 "#234#")
    #zetta.core.ResultDone{:remainder (), :result 234}

    I think i probably should read some attoparsec tutorials -- I'm pretty ignorant of the basics so I'm not sure where to begin fixing (i.e. maybe I've just built things wrong or loaded something incorrectly...)
  3. @roman roman revised this gist Apr 8, 2012. 2 changed files with 13 additions and 10 deletions.
    13 changes: 13 additions & 0 deletions gistfile1.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    (def identifier
    (around
    whitespaces
    (choice
    [(<$> (partial apply vector)
    (*> (string "#")
    (<* number (string "#"))))
    ; ^ I think you should be using just number here right?
    ; you are trying to parse (many1 digit)
    (<$> (partial apply vector)
    (*> (string "#")
    (<* number (string "="))))])))
    ; ^ same applies here
    10 changes: 0 additions & 10 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,10 +0,0 @@
    (def identifier
    (around
    whitespaces
    (choice
    [(<$> (partial apply vector)
    (*> (string "#")
    (<* (many1 number) (string "#"))))
    (<$> (partial apply vector)
    (*> (string "#")
    (<* (many1 number) (string "="))))])))
  4. takeoutweight created this gist Apr 8, 2012.
    10 changes: 10 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    (def identifier
    (around
    whitespaces
    (choice
    [(<$> (partial apply vector)
    (*> (string "#")
    (<* (many1 number) (string "#"))))
    (<$> (partial apply vector)
    (*> (string "#")
    (<* (many1 number) (string "="))))])))