masak / alma

ALgoloid with MAcros -- a language with Algol-family syntax where macros take center stage
Artistic License 2.0
137 stars 14 forks source link

Consider linking Q objects back to from/to parsing positions in the source code #529

Open masak opened 5 years ago

masak commented 5 years ago

tbd example with is parsed hex numbers

tbd no need to do this for synthetic Qnodes (?)

tbd possible uses in other issues: Refactoring tools, that syntax highlighter

vendethiel commented 5 years ago

(Building an actual CST is always so much more tedious than an AST...)

masak commented 5 years ago

@vendethiel Yes, although the tedium here seems to consist only of remembering to attach position information from a Match to a Q. More precisely, we can't mandate it (because synthetic Qnodes need to be constructible without such position information), but what we probably can do is make it very low-friction/attractive to just pass that information somehow from the Match to the new Q.

Guess it's also worth thinking about what the consequences are of some macro author forgetting. (At a guess, we can't track some macro back to where it was in the source; can't do analysis, replacements, syntax highlighting, etc.) Thirdly, maybe there are places where position information shouldn't or can't be given? I dunno.

vendethiel commented 5 years ago

Of possible interest: Racket's syntax objects, which keep source location & lexical context.