[climacs-devel] Re: LR parser
Nicolas Sceaux
nicolas.sceaux at free.fr
Tue Dec 27 16:07:10 UTC 2005
John Q Splittist <splittist at yahoo.com> writes:
> Nicolas Sceaux wrote:
>> John Q Splittist <splittist at yahoo.com> writes:
>
>>> The purpose of this project is to (a) ex-tract the parser
>>> functionality from the lisp-syntax file then (b) ab-stract that
>>> functionality to make it easier to specify a grammar.
>> I've made an (naive) attempt at task (a). Patch is attached, and
>> comments most welcome.
>
> Nicolas,
>
> Do you want to continue on to part (b)? If so, do you want gardener
> help? I'm sure Robert et al would be willing to help you co-ordinate a
> team/another person if that's the way you want to go.
I'd like to continue on part b, yes. And indeed, I need some advice on
how/what to do first (and I'd also like to hear Robert about that,
embedded language courses at ENSERB were too few ;)
1) The lexer part, ie defining lexer states, lexeme types, and LEX methods,
is well readable and understandable as it is. However, with some other
languages, you may want to define the same bits of the lexer for different
lexer states. When using lex/flex, you can say eg:
<lexer-state1,lexer-state2>some-regex { return some-lexeme-type; }
Maybe some syntax for defining the same bits of lexing for several lexer
states would be helpful for other syntaxes.
(with-lexer-definition (initial-lexer-state inner-block-lexer-state some-other-state)
some-syntax
...
(define-lex-rule-by-string "\\include" (initial-lexer-state inner-block-lexer-state)
(make-instance 'include-lexeme))
...)
2) The grammar definition in lisp-syntax.lisp is a bit more opaque. I've
been thinking about a syntax for defining the grammar, maybe something
like:
(define-lisp-parser-state-rules
;; (new-parser-state -> parser-state parser-symbol)
(|( form* | -> form-may-follow left-parenthesis-lexeme)
(|( form* | -> |( form* | form)
(|( form* | -> |( form* | comment)
(|( form* ) | -> |( form* | right-parenthesis-lexeme))
(define-lisp-parser-reductions
;; (parser-symbol -> parser-state lexeme :reduce-keyword [reduce-arg])
;; reduce according to the rule form -> ( form* )
(complete-list-form -> |( form* ) | t :until-type left-parenthesis-lexeme)
;; reduce at the end of the buffer
(incomplete-form-mixin -> |( form* | nil :until-type left-parenthesis-lexeme))
nicolas
More information about the climacs-devel
mailing list