adapted to changed interface of parser
[software/python-on-guile.git] / modules / language / python / parser.scm
1 (define-module (language python parser)
2 #:use-module (logic guile-log)
3 #:use-module (ice-9 match)
4 #:use-module (ice-9 pretty-print)
5 #:use-module (language python parser-tool)
6 #:export (p))
7
8 (define do-print #t)
9 (define pp
10 (case-lambda
11 ((s x)
12 (when do-print
13 (pretty-print `(,s ,(syntax->datum x))))
14 x)
15 ((x)
16 (when do-print
17 (pretty-print (syntax->datum x)))
18 x)))
19
20
21 (define divide truncate/)
22 ;; +++++++++++++++++++++++++++++++++++++ SCANNER SUBSECTION
23 (define com (f-seq "#" (f* (f-not f-nl)) f-nl))
24 (define w (f-reg "[\t\r| ]"))
25 (define ws+ (f+ (f-or (f-reg "[\t\r| ]") com)))
26 (define ws* (f+ (f-or (f-reg "[\t\r| ]") com)))
27 (define ws ws*)
28 (define nl f-nl)
29
30 (define (wn_ n i)
31 (<p-lambda> (c)
32 (cond
33 ((> i n) <fail>)
34 ((= i n)
35 (.. ((f-not w) c)))
36 ((< i n)
37 (<or>
38 (<and>
39 (.. (c) ((f-tag " ") c))
40 (.. ((wn_ n (+ i 1)) c)))
41 (<and>
42 (.. (c) ((f-tag "\t") c))
43 (.. ((wn_ n (divide (+ i 8) 8)) c)))
44 (<and>
45 (.. (c) ((f-tag "\r") c))
46 (.. ((wn_ n i) c))))))))
47
48 (define (wn+_ n i)
49 (<p-lambda> (c)
50 (cond
51 ((> i n)
52 (<with-bind> ((INDENT (cons i INDENT)))
53 (<p-cc> c)))
54 ((< i n)
55 (<or>
56 (<and>
57 (.. (c) ((f-tag " ") c))
58 (.. ((wn+_ n (+ i 1)) c)))
59 (<and>
60 (.. (c) ((f-tag "\t") c))
61 (.. ((wn+_ n (divide (+ i 8) 8)) c)))
62 (<and>
63 (.. (c) ((f-tag "\r") c))
64 (.. ((wn+_ n i) c))))))))
65
66 (define (wn+ n) (wn+_ n 0))
67 (define (wn n) (wn_ n 0))
68
69 (define indent= wn)
70 (define indent+ wn+)
71 (define indent-
72 (<p-lambda> (c)
73 (<with-bind> ((INDENT (cdr INDENT)))
74 (<p-cc> c))))
75
76
77 (define ih (f-reg! "a-zA-Z_"))
78 (define i.. (f-or ih (f-reg! "0-9")))
79 (define identifier_ (f-seq ih (f* i..)))
80
81 (define keyw (make-hash-table))
82 (for-each
83 (lambda (x) (hash-set! keyw x #t))
84 '(False None True and as assert break class continue def
85 del elif else except finally for from global if import
86 in is lambda nonlocal not or pass raise return try
87 while with yield))
88
89 (define decimal (mk-token (f-seq (f-reg! "[1-9]") (f* (f-reg! "[0-9]")))))
90 (define oct (mk-token
91 (mk-token
92 (f-seq "0" (f-reg "[oO]") (f+ (f-reg! "[0-7]"))))))
93 (define hex (mk-token
94 (f-seq "0" (f-reg "[xX]") (f+ (f-reg! "[0-7a-fA-F]")))))
95 (define bin (mk-token
96 (f-seq "0" (f-reg "[bB]") (f+ (f-reg! "[01]")))))
97
98 (define integer
99 (<p-lambda> (c)
100 (<and!>
101 (<or>
102 (<and>
103 (.. (c) (decimal c))
104 (<p-cc> (string->number c 10)))
105 (<and>
106 (.. (c) (oct c))
107 (<p-cc> (string->number c 8)))
108 (<and>
109 (.. (c) (hex c))
110 (<p-cc> (string->number c 16)))
111 (<and>
112 (.. (c) (bin c))
113 (<p-cc> (string->number c 2)))))))
114
115 (define intpart (f+ (f-reg! "[0-9]")))
116 (define fraction (f-seq (f-tag! ".") intpart))
117 (define exponent (f-seq (f-reg! "[eE]") (f? (f-reg! "[+-]")) intpart))
118 (define pointfloat (f-or! (f-seq (f? intpart) fraction)
119 (f-seq intpart (f-tag! "."))))
120 (define exponentfloat (f-seq (f-or intpart pointfloat) exponent))
121
122 (define floatnumber (mk-token (f-or! exponentfloat pointfloat)))
123 (define float
124 (<p-lambda> (c)
125 (.. (c) (floatnumber c))
126 (<p-cc> (string->number c))))
127
128 (define imagnumber (mk-token (f-seq (f-or floatnumber integer) (f-reg "[jJ]"))))
129 (define imag
130 (<p-lambda> (c)
131 (.. (c) (imagnumber c))
132 (<p-cc> (string->number (string-append "0+" c "i")))))
133
134 (define (mk-id S c cc) cc)
135
136 (define number
137 (p-freeze 'number
138 (f-or! imag float integer)
139 mk-id))
140
141 (define symbol
142 (let ()
143 (define (__*__ i)
144 (match (string->list i)
145 ((#\_ #\_ . l)
146 (match (reverse l)
147 ((#\_ #\_ . l) #t)
148 (_ #f)))
149 (_ #f)))
150
151 (define (__* i)
152 (match (string->list i)
153 ((#\_ #\_ . l)
154 #t)
155 (_ #f)))
156
157 (define (_* i)
158 (match (string->list i)
159 ((#\_ . l)
160 #t)
161 (_ #f)))
162
163 (<p-lambda> (c)
164 (.. (i) (identifier_ c))
165 (cond
166 ((__*__ i)
167 (#:identifier i #:system))
168 ((__* i)
169 (#:identifier i #:private))
170 ((_* i)
171 (#:identifier i #:local))
172 ((eq? i '_)
173 (#:_))
174 ((hash-ref keyw i)
175 (#:keyword i))
176 (else
177 (#:identifier i))))))
178
179 (define identifier
180 (<p-lambda> (c)
181 (.. (i) (identifier_ c))
182 (when (not (eq? (car i) #:keyword))
183 (<p-cc> c))))
184
185 ;;;; +++++++++++++++++++++++++++++++++++++++++++++++ STRING +++++++++++++++
186 (define string-prefix (mk-token (f-reg! "[ruRU]")))
187 (define short-string-char (f-not! (f-reg "[\n\"']")))
188 (define long-string-char (f-not! "\n"))
189 (define string-esc (f-seq (f-tag "\\") (f-reg! ".")))
190 (define short-string-item (f-or short-string-char string-esc))
191 (define long-string-item (f-or long-string-char string-esc))
192
193 (define long-string
194 (mk-token
195 (f-or
196 (f-seq! "'''" (f* long-string-item) "'''")
197 (f-seq! "\"\"\"" (f* long-string-item) "\"\"\""))))
198
199 (define short-string
200 (mk-token
201 (f-or
202 (f-seq! "'" (f* short-string-item) "'")
203 (f-seq! "\"" (f* short-string-item) "\""))))
204
205 (define string-literal
206 (p-freeze 'string-literal
207 (<p-lambda> (c)
208 (xx (pre) (<or>
209 (.. (string-prefix c))
210 (<p-cc> #f)))
211 (.. (str) (f-or! long-string short-string))
212 (<p-cc> (#:string pre str)))
213 mk-id))
214
215 ;; ++++++++++++++++++++++++++++++++++++++++++ BYTE ++++++++++++++++++++++++++
216
217 (define bytes-prefix
218 (mk-token
219 (f-or!
220 (f-seq! (f-tag! "b") (f-or f-true (f-reg! "[rR]")))
221 (f-seq! (f-tag! "B") (f-or f-true (f-reg! "[rR]")))
222 (f-seq! (f-tag! "r") (f-or f-true (f-reg! "[bB]")))
223 (f-seq! (f-tag! "R") (f-or f-true (f-reg! "[bB]"))))))
224
225 (define bytes-esc (f-seq "\\" (f-reg ".")))
226
227 (define short-bytes-char (f-not! (f-reg "[\\\n'\"]")))
228 (define long-bytes-char (f-not! (f-reg "[\\]")))
229
230 (define short-bytes-item
231 (f-or short-bytes-char bytes-esc))
232
233 (define long-bytes-item
234 (f-or long-bytes-char bytes-esc))
235
236 (define short-bytes
237 (mk-token
238 (f-or! (f-seq! "'" (f* short-bytes-item) "'")
239 (f-seq! "\"" (f* short-bytes-item) " \""))))
240
241 (define long-bytes
242 (mk-token
243 (f-or! (f-seq! "'''" (f* long-bytes-item) "'''")
244 (f-seq! "\"\"\"" (f* long-bytes-item) "\"\"\""))))
245
246 (define bytes-literal
247 (p-freeze 'string-literal
248 (<p-lambda> (c)
249 (.. (pre) (bytes-prefix c))
250 (.. (str) ((f-or! long-bytes short-bytes) pre))
251 (<p-cc> (#:bytes pre str)))
252 mk-id))
253
254
255 ; +++++++++++++++++++++++++++++++++++ PARSER SUBSECTION +++++++++++++++++
256 (define stmt #f)
257 (define testlist #f)
258 (define dotted_name #f)
259 (define arglist #f)
260 (define classdef #f)
261 (define funcdef #f)
262 (define test #f)
263 (define small_stmt #f)
264
265
266 (define expr_stmt #f)
267 (define del_stmt #f)
268 (define pass_stmt #f)
269 (define flow_stmt #f)
270 (define import_stmt #f)
271 (define global_stmt #f)
272 (define nonlocal_stmt #f)
273 (define assert_stmt #f)
274 (define testlist_star_expr #f)
275 (define augassign #f)
276 (define yield_expr #f)
277 (define star_expr #f)
278 (define exprlist #f)
279 (define import_name #f)
280 (define import_from #f)
281 (define dotted_as_names #f)
282 (define import_as_names #f)
283 (define if_stmt #f)
284 (define while_stmt #f)
285 (define for_stmt #f)
286 (define try_stmt #f)
287 (define with_stmt #f)
288 (define suite #f)
289 (define except_clause #f)
290 (define with_item #f)
291 (define expr #f)
292 (define or_test #f)
293 (define lambdef #f)
294 (define lambdef_nocond #f)
295 (define and_test #f)
296 (define not_test #f)
297 (define comparison #f)
298 (define comp_op #f)
299 (define xor_expr #f)
300 (define and_expr #f)
301 (define or_expr #f)
302 (define arith_expr #f)
303 (define shift_expr #f)
304 (define term #f)
305 (define factor #f)
306 (define power #f)
307 (define atom #f)
308 (define trailer #f)
309 (define subscriptlist #f)
310 (define testlist_comp #f)
311 (define dictorsetmaker #f)
312 (define comp_for #f)
313 (define subscript #f)
314 (define sliceop #f)
315 (define argument #f)
316 (define comp_if #f)
317 (define yield_arg #f)
318
319
320 (define file-input (f-seq (f* (f-or nl (f-seq indent= stmt))) f-eof))
321
322 (define eval-input (f-seq testlist (f* nl) f-eof))
323
324 (define decorator (f-cons (f-seq ws "@" ws dotted_name ws)
325 (f-seq (ff? (f-seq "(" ws (ff? arglist) ws ")" ws))
326 f-nl)))
327
328 (define decorators (ff+ decorator))
329
330
331 (define decorated (f-list #:decorated
332 decorators
333 (f-or classdef funcdef)))
334
335 (define FALSE (f-out #f))
336 (define tfpdef
337 (f-cons (f-seq ws identifier ws) (f-or
338 (f-seq ":" ws test ws)
339 FALSE)))
340
341 (define vfpdef identifier)
342 (define mk-py-list
343 (lambda (targlist tfpdef)
344 (let* ((t (f-or (f-seq "=" ws test ws) FALSE))
345 (arg (f-list ws tfpdef ws t ws))
346 (arg.. (ff* (f-seq ws "," arg)))
347 (args (f-cons arg arg..))
348 (arg* (f-seq ws "*" ws (f-list tfpdef ws arg..)))
349 (arg** (f-seq ws "**" tfpdef)))
350 (f-cons
351 (f-out targlist)
352 (f-or
353 (f-cons args
354 (f-or (f-list arg* (f-or arg** FALSE))
355 (f-list FALSE FALSE)))
356 (f-list FALSE arg* (f-or arg** FALSE))
357 (f-list FALSE FALSE arg**))))))
358
359 (define typedargslist (mk-py-list #:types-args-list tfpdef))
360 (define varargslist (mk-py-list #:var-args-list vfpdef))
361
362 (define parameters (f-seq! (f-tag "(") (f-or typedargslist
363 (f-out (list #f #f #f)))
364 (f-tag ")")))
365
366 (set! funcdef
367 (p-freeze 'funcdef
368 (<p-lambda> (c)
369 (.. (c) ((f-tag "def") c))
370 (.. (c) (ws c))
371 (.. (id) (identifier c))
372 (.. (c) (ws id))
373 (.. (pa) (parameters c))
374 (.. (c) (ws pa))
375 (.. (te) ((ff? (f-seq! ws "->" ws test)) c))
376 (.. (su) (f-seq! ":" ws suite))
377 (<p-cc> (list #:funcdef id pa te su)))
378 mk-id))
379
380 (define simple_stmt (f-list #:stmt
381 (f-seq
382 (f-cons small_stmt
383 (ff* (f-seq ";" small_stmt)))
384 ws (f? ";") ws nl)))
385 (set! small_stmt
386 (f-or expr_stmt del_stmt pass_stmt flow_stmt import_stmt global_stmt
387 nonlocal_stmt assert_stmt))
388
389 (set! expr_stmt
390 (f-seq testlist_star_expr
391 (f-or
392 (f-seq augassign
393 (f-or (f-or yield_expr testlist)
394 (f* (f-seq "="
395 (f-or yield_expr
396 testlist_star_expr))))))))
397
398 (set! testlist_star_expr
399 (f-cons (f-or test star_expr)
400 (f-seq
401 (ff* (f-seq "," (f-or test star_expr)))
402 (f? ","))))
403
404
405 (set! augassign
406 (mk-token
407 (f-seq
408 ws
409 (apply f-or!
410 (map f-tag
411 '("+=" "-=" "*=" "/=" "%=" "&=" "|=" "^="
412 "<<=" ">>=" "**=" "//=")))
413 ws)))
414
415 (set! del_stmt (f-cons #:del (f-seq "del" exprlist)))
416
417 (set! pass_stmt (f-seq "pass" #:pass))
418
419 (set! flow_stmt
420 (f-or
421 (f-seq "break" #:break)
422 (f-seq "coninue" #:continue)
423 (f-cons #:return (f-seq "return" (ff? testlist)))
424 yield_expr
425 (f-cons #:raise (f-seq "raise"
426 (f-or (f-cons test
427 (ff?
428 (f-seq "from" test)))
429 (f-cons FALSE FALSE))))))
430
431 (set! import_stmt (f-or import_name import_from))
432
433 (set! import_name (f-seq "import" dotted_as_names))
434
435 (define dottir (mk-token (f-or! (f-tag! "...") (f-tag! "."))))
436 (define dots* (ff* dottir))
437 (define dots+ (ff+ dottir))
438
439 (set! import_from
440 (f-seq "from"
441 (f-cons
442 (f-or (f-cons dots* dotted_name) dots+)
443 (f-seq "import" (f-or "*"
444 (f-seq "(" import_as_names ")")
445 import_as_names)))))
446
447 (define import_as_name
448 (f-cons identifier (ff? (f-seq "as" identifier))))
449
450 (define dotted_as_name
451 (f-cons dotted_name (ff? (f-seq "as" identifier))))
452
453 (set! import_as_names
454 (f-seq
455 (f-cons import_as_name (ff* (f-seq "," import_as_name)))
456 (f? ",")))
457
458 (set! dotted_as_names
459 (f-cons dotted_as_name (ff* (f-seq "," dotted_as_name))))
460
461 (set! dotted_name
462 (f-cons identifier (ff* (f-seq "." identifier))))
463
464 (define comma_name
465 (f-cons identifier (ff* (f-seq "," identifier))))
466
467 (set! global_stmt
468 (f-cons #:global (f-seq "global" comma_name)))
469
470 (set! nonlocal_stmt
471 (f-cons #:nonlocal (f-seq "nonlocal" comma_name)))
472
473 (set! assert_stmt
474 (f-cons #:assert
475 (f-seq "assert" (f-cons test (ff* (f-seq "," test))))))
476
477
478 (define compound_stmt
479 (f-or! if_stmt while_stmt for_stmt try_stmt with_stmt funcdef classdef
480 decorated))
481
482 (define single_input (f-or! (f-seq (f-pk 1) indent= simple_stmt)
483 (f-seq (f-pk 2) indent= compound_stmt nl)
484 (f-seq (f-pk 0) nl)))
485
486 (set! stmt (f-or simple_stmt compound_stmt))
487
488 (set! if_stmt
489 (f-cons
490 #:if
491 (f-seq
492 "if"
493 (f-cons test
494 (f-seq ":"
495 (f-cons suite
496 (f-cons
497 (ff+ (f-seq "elif"
498 (f-cons test
499 (f-seq ":" suite))))
500 (ff? (f-seq "else" ":" suite)))))))))
501
502 (set! while_stmt
503 (f-cons
504 #:while
505 (f-seq "while"
506 (f-cons test
507 (f-seq ":"
508 (f-cons suite
509 (ff? (f-seq "else" ":" suite))))))))
510
511 (set! for_stmt
512 (f-cons
513 #:for
514 (f-seq "for"
515 (f-cons exprlist
516 (f-seq "in"
517 (f-cons testlist
518 (f-cons (f-seq ":" suite)
519 (ff? (f-seq "else" ":" suite)))))))))
520
521 (set! try_stmt
522 (f-cons
523 #:try
524 (f-seq ws "try" ":"
525 (f-cons suite
526 (f-or
527 (f-cons
528 (ff+ (f-seq except_clause ":" suite))
529 (f-cons
530 (ff? (f-seq "else" ":" suite))
531 (ff? (f-seq "finally" ":" ws suite))))
532 (f-cons
533 FALSE
534 (f-cons
535 FALSE
536 (f-seq "finally" ":" suite))))))))
537
538 (set! with_stmt
539 (f-cons
540 #:with
541 (f-seq "with"
542 (f-cons
543 (f-cons with_item
544 (ff* (f-seq "," with_item)))
545 (f-seq ":" suite)))))
546
547 (set! with_item
548 (f-cons test (f-seq "as" expr)))
549
550 (set! except_clause
551 (f-seq "except"
552 (ff? (f-cons test (ff? (f-seq "as" identifier))))))
553
554 (set! suite
555 (f-cons #:suite
556 (f-or (f-list simple_stmt)
557 (f-seq nl indent+
558 (f-cons stmt
559 (ff* (f-seq indent= stmt)))
560 indent-))))
561
562 (set! test
563 (f-or
564 (f-cons #:if
565 (f-cons (f-seq "if" or_test)
566 (f-seq "else" test)))
567 lambdef
568 (f-cons (f-out #f)
569 (f-cons or_test FALSE))))
570
571
572 (define test_nocond
573 (f-or or_test lambdef_nocond))
574
575 (set! lambdef
576 (f-cons
577 #:lambdef
578 (f-cons (f-seq "lambda" (ff? varargslist '()))
579 (f-seq ":" test))))
580 (set! lambdef_nocond
581 (f-cons
582 #:lambdef
583 (f-cons (f-seq "lambda" (ff? varargslist '()))
584 (f-seq ":" test_nocond))))
585
586 (set! or_test
587 (f-or! (f-cons #:or (f-cons and_test (ff+ (f-seq "or" and_test))))
588 and_test))
589
590 (set! and_test
591 (f-or! (f-cons #:and (f-cons not_test (ff* (f-seq "and" not_test))))
592 not_test))
593
594 (set! not_test
595 (f-or!
596 (f-cons #:not (f-seq "not" not_test))
597 comparison))
598
599 (set! comparison
600 (f-or!
601 (f-cons #:comp
602 (f-cons expr
603 (ff+ (f-cons comp_op expr))))
604 expr))
605
606 (set! comp_op
607 (f-or!
608 (f-seq (f-seq "not" "in" ) (f-out "notin"))
609 (f-seq (f-seq "is" "not") (f-out "isnot"))
610 (apply f-or!
611 (map (lambda (x) (f-seq x (f-out x)))
612 '("<" ">" "==" ">=" "<=" "<>" "!=" "in" "is")))))
613
614
615 (set! star_expr (f-cons #:starexpr (f-seq "*" expr)))
616 (set! expr
617 (f-or!
618 (f-cons #:bxor (f-cons xor_expr (ff+ (f-seq "|" xor_expr))))
619 xor_expr))
620 (set! xor_expr
621 (f-or!
622 (f-cons #:band (f-cons and_expr (ff+ (f-seq "^" and_expr))))
623 and_expr))
624
625 (set! and_expr
626 (f-or!
627 (f-cons #:band (f-cons shift_expr (ff+ (f-seq "&" shift_expr))))
628 shift_expr))
629
630 (set! shift_expr
631 (f-or!
632 (f-cons #:<< (f-cons arith_expr (ff+ (f-seq "<<" arith_expr))))
633 (f-cons #:>> (f-cons arith_expr (ff+ (f-seq ">>" arith_expr))))
634 arith_expr))
635
636 (set! arith_expr
637 (f-or!
638 (f-cons #:+ (f-cons term (ff+ (f-seq "+" term))))
639 (f-cons #:- (f-cons term (ff+ (f-seq "-" term))))
640 term))
641
642 (set! term
643 (f-or!
644 (f-cons #:* (f-cons factor (ff+ (f-seq "*" factor))))
645 (f-cons #:// (f-cons factor (ff+ (f-seq "//" factor))))
646 (f-cons #:/ (f-cons factor (ff+ (f-seq "/" factor))))
647 (f-cons #:% (f-cons factor (ff+ (f-seq "%" factor))))
648 factor))
649
650
651 (set! factor
652 (f-or!
653 (f-cons #:u+ (f-seq "+" factor))
654 (f-cons #:u- (f-seq "-" factor))
655 (f-cons #:u~ (f-seq "~" factor))
656 power))
657
658 (set! power
659 (f-cons #:power
660 (f-cons atom
661 (f-cons (ff* trailer)
662 (f-or! (f-seq "**" factor)
663 FALSE)))))
664
665 (set! trailer
666 (f-or!
667 (f-seq "(" (ff? arglist) ")")
668 (f-seq "[" subscriptlist "]")
669 (f-seq "." identifier)))
670
671 (set! atom
672 (f-or!
673 (f-cons
674 #:subexpr
675 (f-seq "(" ff? (f-or! yield_expr testlist_comp) ")"))
676 (f-cons
677 #:list
678 (f-seq "[" (ff? testlist_comp) ")"))
679 (f-cons
680 #:dict
681 (f-seq "{" (ff? dictorsetmaker) "}"))
682 identifier
683 number
684 (f-cons #:string (ff+ string))
685 (f-cons #:... "...")
686 (f-cons #:None "None")
687 (f-cons #:True "True")
688 (f-cons #:false "False")))
689
690 (set! testlist_comp
691 (f-cons
692 (f-or! star_expr test)
693 (f-or!
694 comp_for
695 (f-seq (ff* (f-seq "," (f-or! star_expr test)))
696 (f? ",")))))
697
698 (set! subscriptlist
699 (f-cons
700 subscript
701 (f-seq (ff* (f-seq "," subscript)) (f? ","))))
702
703 (set! subscript
704 (f-or!
705 (f-list (ff? test) ":" (ff? test) (ff? sliceop))
706 (f-list test FALSE FALSE)))
707
708 (set! sliceop
709 (f-seq ":" (ff? test)))
710
711 (define exprlist
712 (let ((f (f-or expr star_expr)))
713 (f-cons f (f-seq (ff* (f-seq "," f)) (f? ",")))))
714
715 (set! testlist
716 (f-cons
717 test
718 (f-seq (ff* "," test) (f? ","))))
719
720 (set! dictorsetmaker
721 (let ((f (f-cons test (f-seq ":" test))))
722 (f-or!
723 (f-cons* f (f-seq (ff* (f-seq "," f)) (f? ",")))
724 (f-cons f comp_for)
725 (f-cons test comp_for)
726 (f-cons test (f-seq (ff* (f-seq "," test)) (f? ","))))))
727
728 (set! classdef
729 (f-list
730 #:classdef
731 (f-seq "class" identifier)
732 (ff? (f-seq "(" (ff? arglist '()) ")"))
733 (f-seq ":" suite)))
734
735 (set! arglist
736 (f-or!
737 (f-list (f-seq (ff+ (f-seq argument ",")) (f? ","))
738 FALSE FALSE)
739 (f-list (f-seq (ff* (f-seq argument ",")))
740 FALSE
741 (ff? (f-seq "**" test)))
742 (f-list (f-seq (ff* (f-seq argument ",")))
743 (f-seq "*" (f-cons test (ff* (f-seq "," argument))))
744 (ff? (f-seq "," "**" test)))))
745
746 (set! argument
747 (f-or!
748 (f-list #:= test (f-seq "=" test))
749 (f-list #:comp test (ff? comp_for))))
750
751 (define comp_iter (f-or! comp_for comp_if))
752 (define comp_for (f-list (f-seq "for" exprlist)
753 (f-seq "in" or_test)
754 (ff? comp_iter)))
755 (set! comp_if (f-list (f-seq "if" test_nocond)
756 (ff? comp_iter)))
757
758 (set! yield_expr
759 (f-list #:yield (f-seq "yield" (ff? yield_arg))))
760
761 (set! yield_arg
762 (f-or!
763 (f-list #:from (f-seq "from" test))
764 (f-list #:list testlist)))
765
766
767 (define (p str)
768 (pp (parse str single_input))
769 (if #f #f))