(facetious-comment "It's a tragedy how much brilliance is wasted on grammar parsing when it's a solved problem; just use a Lisp")
The difference between top-down parsing and bottom-up parsing
41–45 of 45 posts
Re: The difference between top-down parsing and bottom-up parsing
#42What do you call it if you're just using a big list of regexes? I've seen that used for a simple dialog scripting language in a game.
But it depends on how the list of regexes is used. If it is used as part of a recursive paring routine, then it is a recursive-descent parser where lexing and parsing happens in the same pass.
Re: The difference between top-down parsing and bottom-up parsing
#43Earlier quoted context omitted.
Could you expand on this? What's a memoized token stream?
A token stream that preserves token identities. Say you have a token stream of [t0, t1] and add a new token t2 between t0 and t1 to get [t0, t2, t1]. What you want is to be able to identify t0 and t1 in the new stream as being the same tokens as in the old stream. If you simply re-lex to get new tokens, that won't happen, and if you use character offsets as your token identities, t1 in the new and old stream will hav…
Re: The difference between top-down parsing and bottom-up parsing
#44Earlier quoted context omitted.
A token stream that preserves token identities. Say you have a token stream of [t0, t1] and add a new token t2 between t0 and t1 to get [t0, t2, t1]. What you want is to be able to identify t0 and t1 in the new stream as being the same tokens as in the old stream. If you simply re-lex to get new tokens, that won't happen, and if you use character offsets as your token identities, t1 in the new and old stream will hav…
Thanks. To figure out what's damaged, it seems like you have to do a diff somewhere? It sounds like this is done at the character level rather than the token level?
Re: The difference between top-down parsing and bottom-up parsing
#45Earlier quoted context omitted.
JSON or XML would also work. Except that few people like languages based on XML, and I haven't seen anyone seriously try JSON. Perhaps someone should try to build a JSON-like language that's close to how most programmers like to write their code?
Yeah, this is why no one likes languages based on XML: http://thedailywtf.com/articles/We-Use-BobX If you were going to do it, I'm certain you'd want to use a more human-writable format such as YAML or TOML instead of JSON or XML. But doing so means you're living out Greenspun's Tenth Rule. Again, just use a Lisp. http://www.defmacro.org/ramblings/lisp.html