[climacs-devel] grammar definition

Nicolas Sceaux nicolas.sceaux at free.fr
Thu Jan 5 21:57:07 UTC 2006


Hello,

I've been experimenting a bit with various ways of defining a grammar
like lisp-syntax' one for the LR parser, but I'm not really satisfied and
I'm sure gurus here have some better thoughts about it.


  (define-grammar lisp-syntax (some options)

    ;; Expand to define-parser-state
    ;; (<state> => <specialized-state>)

    ;; Expand to define-new-parser-state:
    ;; (<new-state> => <state> <parse-tree>)
  
    ;; Expand to defclass of nonterminals:
    ;; (<nonterminal> -> <specialized-nonterminal>)

    ;; Expand to define-action:
    ;; (<nonterminal> -> <state> <lexeme> <how-to-reduce>)
    
    ;;;;;;; List
    (form               -> list-form)
    (list-form          -> complete-list-form)
    (complete-list-form -> |( form* ) | t
     :reduce-until-type left-parenthesis-lexeme)

    (lexer-list-state     => |( form* |)
    (form-may-follow      => |( form* |)
    (parser-state         => |( form* ) |)
    (lexer-toplevel-state => |( form* ) |)
    (|( form* |   => form-may-follow left-parenthesis-lexeme)
    (|( form* |   => |( form* | form)
    (|( form* |   => |( form* | comment)
    (|( form* ) | => |( form* | right-parenthesis-lexeme)

    (list-form             -> incomplete-list-form)
    (incomplete-form-mixin -> incomplete-list-form)
    (incomplete-list-form  -> |( form* | nil 
     :reduce-until-type left-parenthesis-lexeme))
  
But I'm not sure what kind of utility people expect. I'd be glad to be
put on the right track.

nicolas



More information about the climacs-devel mailing list