Pattern matching in Racket-language has ... to do greedy matching( match 0 or more ), what if I want to match something like this:
#lang racket
(define (Modifier? t) (equal? t "Modifier"))
(define (SimpleName? t) (equal? t "SimpleName"))
(define (SimpleType? t) (equal? t "SimpleType"))
(define (FieldDeclaration? t) (equal? t "FieldDeclaration"))
(match (match '("FieldDeclaration" ("Modifier") ("Modifier") ("SimpleType") ("VariableDeclarationFragment" ("SimpleName") ("StringLiteral")))
[(list (? FieldDeclaration? id) (? Modifier? m) ... (? SimpleType? t) (list _ (? SimpleName? n)) _ ...)
'yes]
[else 'no] )
which print 'no ,while I expect 'yes. I guess it caused by ... which do a greedy matching (just search "greedy" in the linked page) ,However I'm not quite sure about this ....)
there can be 0 to 3 ("Modifier") s in the list, so how can I match this form? ( Actually ,there are more things to do in the function XXX? so I have to use the form (? XXX? x) )
PS: Does it possible to extend the matching syntax so I can use something like n_m which means matching n to m times ,just like {n,m} in regular expression?