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.