Hi,
I wrote lexer return (values (intern "{") (intern "{")) but when using LR parser, the following error occurs. I have red the code expanded by macro, and found that the second argument is evaluated, which should be (intern "{"). If the lexer return (values '{ '{), it works. So is there any way to use string to symbol function in lexer? Thanks, Haiwei
Unknown terminal { [Condition of type SIMPLE-ERROR]
Restarts: 0: [ABORT] Return to SLIME's top level. 1: [TERMINATE-THREAD] Terminate this thread (#<THREAD "new-repl-thread" {AEFFD89}>)
Backtrace: 0: ((LAMBDA (#:G203 #:G205 #:G206)) 6 #<unavailable argument> (0 #<CLOSURE # {AEE11B5}> #<FUNCTION # {AED86B5}> #2A((# # #S(FUCC::ERROR-ACTION) #S(FUCC::ERROR-ACTION) #S(FUCC::ERROR-ACTION) #S(FUCC::ERROR-ACTION) #S(FUCC::ERROR-ACTION) # #S(FUCC::ERROR-ACTION) # ...) (#S(FUCC::ERROR-ACTION) # # # # # # #S(FUCC::ERROR-ACTION) #S(FUCC::ERROR-ACTION) # ...) (#S(FUCC::ACCEPT-ACTION) #S(FUCC::ERROR-ACTION) ..)))) Locals: SB-DEBUG::ARG-0 = 6 SB-DEBUG::ARG-1 = :<NOT-AVAILABLE> SB-DEBUG::ARG-2 = (0 #<CLOSURE (LAMBDA #) {AEE11B5}> #<FUNCTION (LAMBDA #) {AED86B5}>
On 10225 day of my life highfly joe wrote:
So is there any way to use string to symbol function in lexer?
Do you mean "in parser"?
Parser have to know all terminals and non-terminals in compile time (to build internal tables). Arguments of defparser are not evaluated for this reason (To avoid confusion, warning should be signaled if you pass a non-atom in terminal list; I will improve it in future version).
You may use read-time evaluation intoduced by #. read macro:
(fucc:defparser *test* s ; Initial ;; List of terminals: (term1 term2 #.(intern "{"))) ;; List of rules: (s -> term2 term1 -> #.(intern "{"))))
Or even
(fucc:defparser *test* s ; Initial ;; List of terminals: (term1 term2 #1= #.(intern "{"))) ;; List of rules: (s -> term2 term1 -> #1#))
But isn't simple { better?
I also prefer using keywords for terminals: :{ works fine even if looks somewhats dreary, but it is compensated by :} terminal.