Skip to content

Commit

Permalink
shortening some line number nodes; too many had the file name
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Sep 26, 2011
1 parent d48d6cd commit 04ebeaa
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
16 changes: 16 additions & 0 deletions doc/todo
Original file line number Diff line number Diff line change
Expand Up @@ -804,3 +804,19 @@ this (and tintersect on NTuple) is needed to define Array() methods in boot.j

* call inference on general thunks so we don't need to make GFs for them
in toplevel_eval

-------------------------------------------------------------------------------

counts of expression types:

static int n_expr=0; // 252767
static int n_call=0; // 87436
static int n_top=0; // 31118
static int n_oth=0; // 20502 body,locals,enter,leave
// 19559 ::
static int n_assi=0; // 18926
static int n_quot=0; // 15003
static int n_ret=0; // 11827
// 10061 lambda
static int n_goti=0; // 6286
static int n_goto=0; // 6227
38 changes: 23 additions & 15 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,10 @@
(or (eof-object? tok)
(memv tok '(#\) #\] #\} else elseif catch))))

(define (loc-header s)
(define (line-number-node s)
`(line ,(input-port-line (ts:port s))))

(define (line-number-filename-node s)
`(line ,(input-port-line (ts:port s)) ,current-filename))

; parse a@b@c@... as (@ a b c ...) for some operator @
Expand All @@ -318,8 +321,8 @@
(if (and allow-empty (eqv? (require-token s) op))
'()
(if (eqv? op #\newline)
(let ((loc (loc-header s)))
;; note: loc-header must happen before (down s)
(let ((loc (line-number-node s)))
;; note: line-number must happen before (down s)
(list (down s) loc))
(list (down s)))))
(first? #t))
Expand Down Expand Up @@ -629,17 +632,22 @@
(parse-comma-separated-assignments s))))
((function)
(let* ((paren (eqv? (require-token s) #\())
(sig (parse-call s)))
(begin0 (list word
(if (symbol? sig)
(if paren
;; in "function (x)" the (x) is a tuple
`(tuple ,sig)
;; function foo => syntax error
(error "expected ( in function definition"))
sig)
(parse-block s))
(expect-end s))))
(sig (parse-call s))
(def (if (symbol? sig)
(if paren
;; in "function (x)" the (x) is a tuple
`(tuple ,sig)
;; function foo => syntax error
(error "expected ( in function definition"))
sig))
(loc (line-number-filename-node s))
(body (parse-block s)))
(expect-end s)
(if (and (length> body 1)
(pair? (cadr body))
(eq? (caadr body) 'line))
(set-car! (cdr body) loc))
(list word def body)))
((macro)
(let ((sig (parse-call s)))
(begin0 (list word sig (parse-block s))
Expand Down Expand Up @@ -1115,7 +1123,7 @@
(eq? (car ex) '=)
(pair? (cadr ex))
(eq? (caadr ex) 'call))
;; insert loc-header for short-form function defs
;; insert line/file for short-form function defs
`(= ,(cadr ex) (block (line ,lno ,current-filename) ,(caddr ex)))
ex)))
(let ((s (make-token-stream stream)))
Expand Down

0 comments on commit 04ebeaa

Please sign in to comment.