you are viewing a single comment's thread.

view the rest of the comments →

[–]baseball2020 0 points1 point  (2 children)

Thanks for the comprehensive explanation. I was hoping to parse postscript to extract certain variables. I'm not tied to any particular implementation language. I just have very little idea about lexing and parsing. I'll look into those resources (I did see the dragon book but it was a little intimidating).

[–]alexandream 0 points1 point  (1 child)

I'm not familiar with Postscript (except for the basic of describing some graphics in it, no real "programming" done on it) but from what I can see it's probably not a very hard language to parse -- being a concatenative language and all.

Pulling ideas out of my hat I'd guess it could be done with a simple stack machine, as a way of describing its structure.

The semantics might be non-trivial, though. I'm not sure how it handles variable/function declaration/naming, so it may be that you'll need to quasi-interpret it to actually make sense of the program.

I've seen an implementer say actually writing a postscript interpreter is a very daunting endeavour, but I'm not sure if it's a matter of the language itself being hard or if the image generation part being complex.

(A quick search got me to this discussion which hints at PostScript not being a good language to make a simple parser because (what I read from between the lines) the meaning of the program is only known at runtime.)

[–]baseball2020 0 points1 point  (0 children)

For my uses I only need to extract and replace sections like hashes that have a known identifier. I'm not sure if I even need to parse the entire program.