j kongerblog
mountains and websites

blog

How to match til the end of an input string with a janet peg

aka a parsing expression grammar, aka the only reason i wanna use janet:

to match all the rest of the content in a string, use this:

(any 1)

unlike most else i seen in PEGs, this is hella unclear. it literally means, more or less, match any amount of single characters, but god does that not help. instead, i think of it like “match anyone”: get anyone left.

Janet PEGs don't accept unicode??

nope! not easily, at least. you can match unicode characters, but NOTHING is made easy for you, the way a regex /u flag will. that said, its still possible with use of (to)

look, for example, at a truncated version of a PEG i’m writing to pull info from a french/english dictionary:

(def dict-result-peg
  ~{
    # ... catch some stuff
    :pronunciation (* "/" (to "/") "/")
    # ... and so on
   })
 

i wanna catch all the character in the words IPA prnounciation, which luckily enough are surrounded by /s. since janets PEGs don’t allow for a character class range of unicode prononciation strings, i instead use a (to "/") to grab all the text between delimiters. it’s imprecise, but in this instance perfect, as i know ill never get a / in the prnonciation guide

Kojima San. That move woke...

Kojima San. That move woke…

project finished: i stitched hisoka onto a cap

look at this and be nice, i’m much more sensitive to criticism than talented:

a shitty little ghost kitchen opened near our place, and on opening day they gave away free hats. i pulled out their logo embroidery then (lazily, badly) stitched on a patch.

bonus picture, worn by a posture bunny like a helmet:

this is now a place for completing projects

i swear unto you, i will now be completing projects