-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Treatment of the inclusion command #85
Comments
Yes, this is a limitation of the current implementation in metamath.c. The way it is written doesn't make it easy to fix... |
@digama0 : Is this, roughly writing, because in metamath.c (and mmverify.py), FILENAME is treated by the lexer (I mean: the lexer, upon encountering |
There is a note about it in
So it is actually even more restrictive that the EBNF definition. |
Thanks @tirix. After a rapid look at https://github.com/david-a-wheeler/metamath-knife/blob/071292ef3a10350d0dae9e409b4921f91a08ce95/src/parser.rs it looks that lexing and parsing are kind of merged, with no clear distinction ? Concerning my first question above, if inclusion commands are simply tokenized as Actually, I think that having no reference at all to the "top nesting level" or "outermost scope" in the EBNF would make things clearer, and actually even easier to code. But I haven't thought about multithreading. |
I don't think you need to handle "outermost scope" at the parser level, but it is totally possible to do so - this is a context-free property. I think the majority of metamath verifiers treat $c scoping at verification time, not parse time: at verification time you have a stack of frames so it's easy to tell if you are at the top level. |
You could say so, in the sense that the Handling file inclusion at the parsing level seems sensible to me, and I would also agree to to forbid in our standard the "jokes" you're referring to. I've now had a look at the Book, and indeed it states in chapter 4.1.2:
The specification would have to be relaxed here, for the "outermost scope" part. |
...so to come back at the initial title of this issue, |
Curently, metamath.c (and mmverify.py) treat inclusion commands (
$[ FILENAME $]
) as exact copy-pasting, that is, the content of the file FILENAME is pasted in place of$[ FILENAME $]
in the input stream before lexing. This permits jokes like the following:On the other hand, the EBNF in the book does not permit it. Here, I think that the EBNF way is preferable, and metamath.c is a bit too laxist. Thoughts ? @digama0 ?
The text was updated successfully, but these errors were encountered: