;; @syntax (test <t1> (<t2> <t3>) (<t4> <t5>) ...)
;; test
generates
Quote
t4
syntax: (test t1 (t2 t3) (t4 t5) ...)
test
should be:
Quote
test
syntax: (test t1 (t2 t3) (t4 t5) ...)
test
Also it would be cool to have a trick for a short one line description to pruduce similar:
Quote
test - a test function
syntax: (test t1 (t2 t3) (t4 t5) ...)
test
Yes, parenthesized expressins in syntax patterns cannot be recognized correctly. If you have a patch for this I can incorporate it.
While we are at regular expressions. You asked in another thread how to maintain token-seperator and other information when using 'parse'.
Here is a solution with 'replace' using the replacement function to do the work and report the token seperators:
With 'parse' when can do somthing too, but I have to think about it. Meanwhile you could use 'replace' with a parse grammatik in the search pattern and use a userdefined function in the replacement expression to supply information. Here is a simple example:
> (set 'prog "x=y+z")
(define (foo) (println "token:" $1) (println "separator:" $2) $0)
(replace "([a-z]+)([=+])" prog (foo) 0)
token:x
separator:=
token:y
separator:+
"x=y+z"
Lutz
ps: this does not report handling the character position though. You would have to build a solution with 'regex' which also reports the position.
Lutz,
In the function format-syntax adding "^ *" (link regexp to start of the string and eat leading spaces) in the front of the regexp seems to be a trick for newlispdoc.
(replace {^ *((.*?) (.*?))} text (string "(<font color=#CC0000>" $1 "</font> " $2) 0)
(replace {^ *(([^ ]*?))} text (string "(<font color=#CC0000>" $1 "</font>)") 0)
And thanks for tricks about parsing.