newlispdoc trouble

Notices and updates
Locked
Dmi
Posts: 408
Joined: Sat Jun 04, 2005 4:16 pm
Location: Russia
Contact:

newlispdoc trouble

Post by Dmi »

Code: Select all

;; @syntax (test <t1> (<t2> <t3>) (<t4> <t5>) ...)
;; test
generates
t4
syntax: (test t1 (t2 t3) (t4 t5) ...)
test
should be:
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:
test - a test function
syntax: (test t1 (t2 t3) (t4 t5) ...)
test
WBR, Dmi

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

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:

Code: Select all

> (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.

Dmi
Posts: 408
Joined: Sat Jun 04, 2005 4:16 pm
Location: Russia
Contact:

Post by Dmi »

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.

Code: Select all

(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.
WBR, Dmi

Locked