mirror of
https://github.com/janet-lang/janet
synced 2025-01-13 17:10:27 +00:00
Improve line and col tracking in parser.
Unconditionally add line and column information if a parsed value is a tuple - before, some parsed tuples had line and col information omitted.
This commit is contained in:
parent
92f0e1719b
commit
b7cfc08fc5
@ -953,7 +953,7 @@
|
|||||||
(def [l c] (tuple/sourcemap (dyn :macro-form ())))
|
(def [l c] (tuple/sourcemap (dyn :macro-form ())))
|
||||||
(def cf (dyn :current-file))
|
(def cf (dyn :current-file))
|
||||||
(def fmt-1 (if cf (string/format "trace [%s]" cf) "trace"))
|
(def fmt-1 (if cf (string/format "trace [%s]" cf) "trace"))
|
||||||
(def fmt-2 (if (or (neg? l) (neg? c)) ": " (string/format " on line %d, column %d:" l c)))
|
(def fmt-2 (if (or (neg? l) (neg? c)) ":" (string/format " on line %d, column %d:" l c)))
|
||||||
(def fmt (string fmt-1 fmt-2 " %j is "))
|
(def fmt (string fmt-1 fmt-2 " %j is "))
|
||||||
(def s (gensym))
|
(def s (gensym))
|
||||||
~(let [,s ,x]
|
~(let [,s ,x]
|
||||||
|
@ -167,12 +167,12 @@ static void popstate(JanetParser *p, Janet val) {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
JanetParseState top = p->states[--p->statecount];
|
JanetParseState top = p->states[--p->statecount];
|
||||||
JanetParseState *newtop = p->states + p->statecount - 1;
|
JanetParseState *newtop = p->states + p->statecount - 1;
|
||||||
|
/* Source mapping info */
|
||||||
|
if (janet_checktype(val, JANET_TUPLE)) {
|
||||||
|
janet_tuple_sm_line(janet_unwrap_tuple(val)) = (int32_t) top.line;
|
||||||
|
janet_tuple_sm_column(janet_unwrap_tuple(val)) = (int32_t) top.column;
|
||||||
|
}
|
||||||
if (newtop->flags & PFLAG_CONTAINER) {
|
if (newtop->flags & PFLAG_CONTAINER) {
|
||||||
/* Source mapping info */
|
|
||||||
if (janet_checktype(val, JANET_TUPLE)) {
|
|
||||||
janet_tuple_sm_line(janet_unwrap_tuple(val)) = (int32_t) top.line;
|
|
||||||
janet_tuple_sm_column(janet_unwrap_tuple(val)) = (int32_t) top.column;
|
|
||||||
}
|
|
||||||
newtop->argn++;
|
newtop->argn++;
|
||||||
/* Keep track of number of values in the root state */
|
/* Keep track of number of values in the root state */
|
||||||
if (p->statecount == 1) p->pending++;
|
if (p->statecount == 1) p->pending++;
|
||||||
|
Loading…
Reference in New Issue
Block a user