by finite_jest on 1/16/22, 1:54 AM with 29 comments
by jstimpfle on 1/16/22, 10:11 AM
Storing row/column in file location data is wasteful - just a file offset should be enough. Whenever the row/column coordinates are needed (normally only in user messages) they can be quickly recomputed.
In effect, parsed tokens can be stored as just an offset - a 4 or 8 byte integer.
by da39a3ee on 1/16/22, 5:11 AM
This API is the only bad thing about Rust!
.expect("Could not read file")
It’s so unfortunate to have an API that reads .expect("thing we don’t expect")
I think we should all just forget it’s there and use .unwrap_or_else(|| panic!(“thing we don’t expect”))
by duped on 1/16/22, 9:51 AM
- Tokens are the leaves of your syntax trees
- File locations are relative, not absolute
It's easier to build a parser that doesn't buy into these things, but it's way harder to build tooling and good error messaging if you don't.
by eatonphil on 1/16/22, 6:37 AM
by xvilka on 1/16/22, 4:29 AM
by cgoto89798 on 1/16/22, 5:04 AM
It basically means you can do something like "goto opcode_table[*(++ip)];"
GCC offers it as a non-standard extension to C.
https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
FORTRAN has had it since 1957. But Pascal and C purged "evil computed GOTO" and only offered non-computed goto. Then Java etc. purged non-computed goto.by debdut on 1/16/22, 5:17 AM