Howdy,
Your framework looks very nifty. It will be especially useful to
have one common space where both forms are improved at the same
time.
>In fact writing a specific grammar mode is pretty easy. It mainly
>consists in providing specialized "builders" that convert input
>grammar elements into Elisp forms understandable by a parser.
>
>Specialized builders are installed as function overrides. The
>following overloads are defined:
Great idea!
>Compared to BNF the new BY format enforce a strict separation between
>lexical and syntax related statements.
The old BNF format was moving in this direction already. I will be
glad to see this additional complexity go away.
>Finally, this cleaner grammar framework should simplify future
>enhancements of bovine grammars. For example, to write a new
>`grammar-parsetable-builder' which don't generate `semantic-lambda'
>forms and allows to explicitly produce the Semantic tokens from
>grammar semantic actions. Maybe it would also imply some modification
>of the bovine parser
Would it make sense to be able to specify a function for some aspect
of table generation in the .*y file? If the code generation routines
were more granular, this might be an interesting thing to use.
For example, Emacs Lisp might choose to override a routine that
converts a single %token keyword (not expression tokens) in a special
way such that "%token C[AR]R "c[ad]r" gets magically expanded into any
combination of car, cdr, cadr, cdadr, etc.
>Attached you will find a tarball. I am looking forward to your
>feedback.
Wow, I'm glad I've been making changes in semanticdb only these
days. ;)
In semantic-grammar.el:
>(defconst semantic-grammar-tokens
> ;;DO NOT EDIT! Generated from semantic-grammar.wy - 2002-08-30 00:06+0200
> (wisent-lex-make-token-table
> '(("punctuation"
> (PERCENT . "%")
> (GT . ">")
What does they keyword table have to do with wisent? Isn't this a
lex only activity?
>(defun semantic-grammar-setup-semantic ()
> "Setup buffer for parse."
> ;;DO NOT EDIT! Generated from semantic-grammar.wy - 2002-08-30 00:06+0200
> (progn
> (semantic-install-function-overrides
> '((parse-stream . wisent-parse-stream)))
Can parse-stream be overriden using the
define-override-implementation function, or are the derived modes
getting in the way.
>;; semantic overloaded functions
>(semantic-install-function-overrides
> '(
> ;;(abbreviate-nonterminal . semantic-grammar-abbreviate-nonterminal)
> ;;(summarize-nonterminal . semantic-grammar-summarize-nonterminal)
> ;;(eldoc-current-symbol-info . semantic-grammar-ecsi)
> (nonterminal-children . semantic-grammar-nonterminal-children)
> )
> t 'semantic-grammar-mode)
Here is a second occurance of the override setup.
In wisent-grammar.el:
>(define-derived-mode wisent-grammar-mode semantic-grammar-mode "WY"
> "Major mode for editing Wisent grammars."
> (semantic-install-function-overrides
> '((grammar-parsetable-builder . wisent-grammar-parsetable-builder)
> (grammar-setupcode-builder . wisent-grammar-setupcode-builder)
> )))
How far back does `define-derived-mode' go in Emacs versions? Aren't
there incompatible changes between 20 and 21, or was that 19 and 20?
(I loose track of these things, and I can't get the help off my Emacs
20 for some reason.) I had this problem w/ Checkdoc not too long ago.
While you are in thinking about all this cool grammar management
framework, lend a cycle to a transforming pre-processor. In
particular, C's annoying pre-processor can convert "FOO(thing)" into
"void thing(void)" which is completely different from the text in the
buffer. This will be especially complex since "#define FOO(n) ..."
will also want to be saved as a token, in addition to being stripped
from the input stream.
I know wisent has a pre-processor like step already to convert the old
lex output into something better. This I think is between the lexer
and that stage, transforming the lexical stream into a different set
of tokens.
Anyway, if you have a hook for that somewhere, I'll try to take
advantage of it in a rudimentary way.
If I recall correctly, the next thing you wanted to do was test your
token generation API, possibly changing the format of what is in a
token, yes?
When you are comfortable with this implementation, check it in, and
I'll work at converting my .bnf files into .by files.
Richard will have a few things to do in the doc after this change.
Great stuff!
Eric
--
Eric Ludlam: zappo@..., eric@...
Home: http://www.ludlam.net Siege: http://www.siege-engine.com
Emacs: http://cedet.sourceforge.net GNU: http://www.gnu.org