yes $bracket-apply$
is a macro and i had a strange bad syntax
error i did not understood but now i have registered it with (define-qi-foreign-syntaxes $bracket-apply$)
it works:
(define-qi-foreign-syntaxes $bracket-apply$)
(define Lplot (~> ((read-lines src)) list->vector {_[5 :]} vector->list (△ (~> string-split rest (△ string->number) vector)) ▽))
is parsed by SRFI 105 curly infix in :
(define-qi-foreign-syntaxes $bracket-apply$)
(define Lplot
(~>
((read-lines src))
list->vector
($bracket-apply$ _ 5 :)
vector->list
(△ (~> string-split rest (△ string->number) vector))
▽))
the critical point being {_[5 :]}
parsed and converted in ($bracket-apply$ _ 5 :)
i add too problem with infix parsing with macro, the problem being that you can manipulate a procedure like +
or list
but not a macro like and
because you will get a bad syntax
once evaluated outside the syntax for which it has been defined. The solution i found for manipulate macro is to use it like a syntax with syntax transformers. I do not know if Qi also use syntax transformers.
This day i tried to go further in associating Qi and infix parsing, i added for example ~>
to the list of my known operator having an operator precedence priority given by it position in the list:
in file: operators-list.rkt
(define infix-operators-lst-for-parser-syntax
(list
exponential-operator-syntax
(list #'* #'/ #'%)
(list #'·) ; symbolic logic And
(list #'⊕) ; symbolic logic Xor
(list #'+ #'-)
(list #'<< #'>>)
(list #'& #'∣)
(list #'< #'> #'= #'≠ #'<= #'>= #'<> #'equal?)
(list #'and)
(list #'or)
(list #'~>)
assignment-operator-syntax
definition-operator-syntax
)
)
it is necessary because this list use too being flatten just to know if a scheme symbol is an operator or another procedure.It is used in an infix?
predicate to check if an expression is infix or prefix.
But when running the $nfx$
of SRFI-105 i have a strange error related to Qi modification of the syntax i think. Note that it previously worked well for $brackett-apply$
macro but not with $nfx$
.
(define-qi-foreign-syntaxes $nfx$)
(define Lplot {((read-lines src)) ~> list->vector ~> {_[5 :]} ~> vector->list ~> (△ {string-split ~> rest ~> (△ string->number) ~> vector}) ~> ▽})
it is a bit hard to understand for someone not in the code of Scheme+ and SRFI-105.
$brackett-apply$
is a macro called only when the parser meet some [ ]
$nfx$
is called when the parser meet an infix expression with need (or not depending of my code version) of applying an operator precedence rule when transforming the infix code in prefix sexpr.
On the previous code (sorry it is not simple expression) the code is pre-parsing this way:
(define-qi-foreign-syntaxes $nfx$)
(define Lplot
($nfx$
((read-lines src))
~>
list->vector
~>
($bracket-apply$ _ 5 :)
~>
vector->list
~>
(△ ($nfx$ string-split ~> rest ~> (△ string->number) ~> vector))
~>
▽))
i suppose the more nested $nfx$
is first expanded, but this not important ; And i have this error:(a bit verbose i have activated debug info)
Welcome to DrRacket, version 8.14 [cs].
Language: Determine language from source; memory limit: 8192 MB.
infix? : expr=(.#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:16:39 -4>)
infix? : (a) allowed or not as infix ,check code
infix? : rv=#t
infix? : expr=(.#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:16:39 -4>)
infix? : (a) allowed or not as infix ,check code
infix? : rv=#t
infix? : expr=()
infix? : null expr
infix? : rv=#t
infix? : expr=()
infix? : null expr
infix? : rv=#t
infix? : expr=(.#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:23:46 -4>)
infix? : (a) allowed or not as infix ,check code
infix? : rv=#t
infix? : expr=(.#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:23:46 -4>)
infix? : (a) allowed or not as infix ,check code
infix? : rv=#t
infix? : expr=(.#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:24:75 4>)
infix? : (a) allowed or not as infix ,check code
infix? : rv=#t
infix? : expr=(.#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:24:75 4>)
infix? : (a) allowed or not as infix ,check code
infix? : rv=#t
infix? : expr=(.#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:29:55 4>)
infix? : (a) allowed or not as infix ,check code
infix? : rv=#t
infix? : expr=(.#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:29:55 4>)
infix? : (a) allowed or not as infix ,check code
infix? : rv=#t
infix? : expr=(.#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:32:38 5>)
infix? : (a) allowed or not as infix ,check code
infix? : rv=#t
infix? : expr=(.#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:32:38 5>)
infix? : (a) allowed or not as infix ,check code
infix? : rv=#t
infix? : expr=()
infix? : null expr
infix? : rv=#t
infix? : expr=()
infix? : null expr
infix? : rv=#t
infix? : expr=(.#<syntax:Applications/Racket v8.14/share/pkgs/qi-lib/macro.rkt:87:47 v> .#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:47:17 string-split> .#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:47:30 ~>> .#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:47:33 rest> .#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:47:38 ~>> (.#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:47:42 △> .#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:47:44 string->number>) .#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:47:60 ~>> .#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:47:63 vector>)
infix? : check not start with an operator:#t
infix-rec? : expr=(.#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:47:17 string-split> .#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:47:30 ~>> .#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:47:33 rest> .#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:47:38 ~>> (.#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:47:42 △> .#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:47:44 string->number>) .#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:47:60 ~>> .#<syntax:opt/homebrew/var/www/drive/parsed_files_directory/displayTrajectory3D+.rkt:47:63 vector>)
infix? forbids: op1 without e1 : (not (null? (cdr expr))) :#t
infix? check (op1 e1 ...) : (member-syntax (car expr) oper-lst) : #f
infix? check not (op1 op2 ...) : (not (member-syntax (cadr expr) oper-lst)) :#f
infix? : rv=#f
. . ../../../../../../Users/mattei/Scheme-PLUS-for-Racket/nfx.rkt:41:2: pre-check-!*-generic-infix-parser : arguments do not form an infix expression :terms: '(#<syntax:/Applications/Racket v8.14/share/pkgs/qi-lib/macro.rkt:87:47 v> #<syntax:displayTrajectory3D+.rkt:47:17 string-split> #<syntax:displayTrajectory3D+.rkt:47:30 ~>> #<syntax:displayTrajectory3D+.rkt:47:33 rest> #<syntax:displayTrajectory3D...
>
the main problem is that the Qi modified expression no more form an infix expression:
. . ../../../../../../Users/mattei/Scheme-PLUS-for-Racket/nfx.rkt:41:2: pre-check-!*-generic-infix-parser : arguments do not form an infix expression :terms: '(#<syntax:/Applications/Racket v8.14/share/pkgs/qi-lib/macro.rkt:87:47 v> #<syntax:displayTrajectory3D+.rkt:47:17 string-split> #<syntax:displayTrajectory3D+.rkt:47:30 ~>> #<syntax:displayTrajectory3D+.rkt:47:33 rest> #<syntax:displayTrajectory3D...
. ../../../../../../Users/mattei/Scheme-PLUS-for-Racket/nfx.rkt:41:2: pre-check-!*-generic-infix-parser : arguments do not form an infix expression :terms: '(#<syntax:/Applications/Racket v8.14/share/pkgs/qi-lib/macro.rkt:87:47 v> #<syntax:displayTrajectory3D+.rkt:47:17 string-split> #<syntax:displayTrajectory3D+.rkt:47:30 ~>> #<syntax:displayTrajectory3D+.rkt:47:33 rest>
in fact the problem is that the Qi system has added this in front of my valid infix list expression:
#<syntax:/Applications/Racket v8.14/share/pkgs/qi-lib/macro.rkt:87:47 v>
is suppose v
is a Qi macro or procedure used internally but as i'm modifying the syntax with syntax transformers after the pre-parsing of the reader and after the Qi modification of syntax my infix?
predicate detect that the generated Qi expression is no more infix and it stop .
To be working my macros $nfx$
should be applied before Qi modification, i read Qi is doing it like compilation but i do not know more.
The problem is a bit like macro phase, the order of modifying syntax here is important.
I do not know if there is something to do easily to fix that? i did not know how the Qi system works internally.