package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)(?P<NUMBER>[+-]?[0-9]+\.[0-9]+|-?\+?[\d]+)|(?P<LPAR>\()|(?P<RPAR>\))|(?P<NAME>%?\w\w*\-?>?\w*\!?\??\.? |[\+\-\.]+?)|(?P<BOOL>#t|#f|true|false)|(?P<STRING>^\"[\w].*[\w]*\")|(?P<CHAR>[#|\\a|\b|\\Backspace]+)|(?P<COMMENT>[;;].*$)|(?P<QUOTES>\'+|\"+)|(?P<OP>[\?==|<=|=|>=\-+*/<>])|(?P<IGNORE>[\s\t])`)
var str = `;; Retorna a sequência de Collatz para o número dado
;; Argumento deve ser um número inteiro.
x ;; comentário
:defn collatz n:
:if [n = 1] then:
'(+ 1 2)
#t
#f
true
false
"dsfsfsf-dfjsif"
-12.34
"(das)" ' '
#
#
\a #\Backspace
(list 1)
:elif (even? n) then:
(cons n (collatz [n quotient 2]))
:else:
(cons n (collatz [[3 * n] + 1]))
;; Imprime a sequência de Collatz de 42`
for i, match := range re.FindAllString(str, -1) {
fmt.Println(match, "found at index", i)
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Golang, please visit: https://golang.org/pkg/regexp/