Skip to content

Commit

Permalink
Merge pull request #469 from masatake/scheme-handle-newline-in-defini…
Browse files Browse the repository at this point in the history
…tion-line

Scheme: handle newline in define/set! line
  • Loading branch information
masatake committed Aug 2, 2015
2 parents 1c3667e + b493214 commit e6e4f2f
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 8 deletions.
33 changes: 33 additions & 0 deletions Units/parser-scheme.r/scheme-simple-define.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
a0 input.scm /^(define a0 1)$/;" f
a1 input.scm /^(define a1 "a")$/;" f
a2 input.scm /^(define a2 '(a))$/;" f
a3 input.scm /^(define a3 '(a b))$/;" f
a4 input.scm /^(define a4 '(a . b))$/;" f
a5 input.scm /^(define a5 '(a b c))$/;" f
a6 input.scm /^(define a6 '(a b . c))$/;" f
a7 input.scm /^(define a7 '(a$/;" f
a8 input.scm /^(define a8$/;" f
a9 input.scm /^ a9 '(a b . c))$/;" f
aa input.scm /^ aa$/;" f
b0 input.scm /^(define (b0) 1)$/;" f
b1 input.scm /^(define (b1 a) 1)$/;" f
b2 input.scm /^(define (b2 a b) 1)$/;" f
b3 input.scm /^(define (b3 a . b) 1)$/;" f
b4 input.scm /^(define (b4 a$/;" f
b5 input.scm /^(define (b5$/;" f
b6 input.scm /^(define (b6$/;" f
b7 input.scm /^(define (b7$/;" f
b8 input.scm /^ b8$/;" f
b9 input.scm /^ b9$/;" f
ba input.scm /^ (ba$/;" f
c0 input.scm /^(define ((c0)) 1)$/;" f
c1 input.scm /^(define ((c1) a) 1)$/;" f
c2 input.scm /^(define ((c2) a b) 1)$/;" f
c3 input.scm /^(define ((c3) a . b) 1)$/;" f
c4 input.scm /^(define ((c4) a$/;" f
c5 input.scm /^(define ((c5)$/;" f
c6 input.scm /^(define ((c6)$/;" f
c7 input.scm /^(define ((c7)$/;" f
c8 input.scm /^ c8)$/;" f
c9 input.scm /^ c9)$/;" f
ca input.scm /^ ca)$/;" f
83 changes: 83 additions & 0 deletions Units/parser-scheme.r/scheme-simple-define.d/input.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
(define a0 1)
(define a1 "a")
(define a2 '(a))
(define a3 '(a b))
(define a4 '(a . b))
(define a5 '(a b c))
(define a6 '(a b . c))
(define a7 '(a
b . c))
(define a8
'(a b . c))

(define
a9 '(a b . c))

(define
aa
'(a b . c))

(define (b0) 1)
(define (b1 a) 1)
(define (b2 a b) 1)
(define (b3 a . b) 1)
(define (b4 a
b) 1)
(define (b5
a b) 1)
(define (b6
a . b) 1)
(define (b7
a . b)
1)

(define (
b8
a . b)
1)

(define
(
b9
a . b)
1)

(define
(ba
a . b)
1)

(define ((c0)) 1)
(define ((c1) a) 1)
(define ((c2) a b) 1)
(define ((c3) a . b) 1)
(define ((c4) a
b) 1)
(define ((c5)
a b) 1)
(define ((c6)
a . b) 1)
(define ((c7)
a . b)
1)

(define ((
c8)
a . b)
1)

(define (
(
c9)
a . b)
1)

(define
(
(
ca)
a . b)
1)

;; incomplete input
(define
29 changes: 29 additions & 0 deletions Units/parser-scheme.r/scheme-simple-setbang.d/input.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
(set! a0 1)
(set! a1 #f)
(set! a2 "a")
(set! a3 '(1))
(set! a4 '(1 2))
(set! a5 '(1 2 . 3))
(set! a5 '(1 2 . 3)
)
(set! a6 '(1 2 . 3
))
(set! a7 '(1 2 .
3))
(set! a7 '(1 2
. 3))
(set! a8 '(1
2 . 3))
(set! a9 '(
1 2 . 3))
(set! aa '
(1 2 . 3))
(set! ab
'(1 2 . 3))
(set!
ac '(1 2 . 3))
(set!
ad
'(1 2 . 3))
;; incomplete input
(set!
Empty file.
4 changes: 4 additions & 0 deletions Units/parser-scheme.r/scheme-srfi-30-comment.b/input.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#|
(define a 1)
(set! b #f)
|#
Empty file.
4 changes: 4 additions & 0 deletions Units/parser-scheme.r/scheme-string.b/input.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"
(define a 1)
(set! b #f)
"
31 changes: 23 additions & 8 deletions parsers/scheme.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,19 @@ static void findSchemeTags (void)
(cp [2] == 'E' || cp [2] == 'e') &&
(cp [3] == 'F' || cp [3] == 'f'))
{
while (!isspace (*cp))
while (*cp != '\0' && !isspace (*cp))
cp++;
/* Skip over open parens and white space */
while (*cp != '\0' && (isspace (*cp) || *cp == '('))
cp++;
do {
while (*cp != '\0' && (isspace (*cp) || *cp == '('))
cp++;
if (*cp == '\0')
cp = line = fileReadLine ();
else
break;
} while (line);
if (line == NULL)
break;
readIdentifier (name, cp);
makeSimpleTag (name, SchemeKinds, K_FUNCTION);
}
Expand All @@ -79,13 +87,20 @@ static void findSchemeTags (void)
(cp [2] == 'E' || cp [2] == 'e') &&
(cp [3] == 'T' || cp [3] == 't') &&
(cp [4] == '!' || cp [4] == '!') &&
(isspace (cp [5])))
(isspace (cp [5]) || cp[5] == '\0'))
{
while (*cp != '\0' && !isspace (*cp))
cp++;
cp += 5;
/* Skip over white space */
while (isspace (*cp))
cp++;
do {
while (*cp != '\0' && isspace (*cp))
cp++;
if (*cp == '\0')
cp = line = fileReadLine ();
else
break;
} while (line);
if (line == NULL)
break;
readIdentifier (name, cp);
makeSimpleTag (name, SchemeKinds, K_SET);
}
Expand Down

0 comments on commit e6e4f2f

Please sign in to comment.