-
Notifications
You must be signed in to change notification settings - Fork 16
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
WIP:Format formalization #30
Open
guygastineau
wants to merge
3
commits into
SENPAI-Molecular-Dynamics:master
Choose a base branch
from
guygastineau:format-formalization
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
;; | ||
;; BNF formalization of MDS file grammar. | ||
;; | ||
|
||
;; | ||
;; This specification takes some liberties to reduce absurd verbosity. | ||
;; Care must be taken to ensure the extensions are explained in clear terms | ||
;; accompanied by proofs if necessary. Given the 'classes', identifiers | ||
;; between angle-brackets '<' and '>', as sets, set theory operations | ||
;; will be used to describe other classes when convenient. To make things | ||
;; clearer the regular equality sign will be used when the right side of a | ||
;; class definition uses set operations and their notation. General use | ||
;; of `where` will also be used for the addition of lexically scoped | ||
;; classes when convenient. | ||
;; | ||
|
||
<whitespace> ::= " " | ||
<ws> ::= <whitespace> | ||
|
||
<optional-whitespace> ::= " " | "" | ||
<opt-ws> ::= <optional-whitespace> | ||
|
||
;; <newline> is used to stick each component/record of the format together. | ||
;; As such, it is illegal inside <string> | ||
<newline> ::= \n | \r\n | <whitespace> <newline> | ||
<nl> ::= <newline> | ||
|
||
;; Any characters that are not valid for <newline>. | ||
<line> ::= <character'> | <character'> <string> | ||
where | ||
<character'> = <newline> △ <character> | ||
|
||
;; Do we need all of utf8? | ||
;; I tend to prefer generality, but maybe this is too much. | ||
<character> ::= <set of all valid utf8> | ||
|
||
<substrate> ::= <line> | ||
|
||
<author> ::= <line> | ||
|
||
<description> ::= <line> | ||
|
||
<digit> ::= 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | ||
|
||
<digits> ::= <digit> | <digit><digits> | ||
|
||
<int> ::= -<digits> | <digits> | +<digits> | ||
|
||
<double> ::= -<double'> | <double'> | +<digits> | ||
where | ||
<double'> ::= <digits>.<digits> | ||
|
||
<atom> ::= <x> <ws> <y> <ws> <z> <ws> <id> <ws> <charge> | ||
where | ||
<x>, | ||
<y>, | ||
<z> ::= <double> | ||
<id> ::= <int> | ||
<charge> ::= <double> | ||
|
||
<atom-block> ::= <atom> | <atom-block> <newline> <atom> | ||
|
||
<bond> ::= <x> <ws> <y> <ws> <K> | ||
where | ||
<x>, <y> ::= <int> | ||
<K> ::= <double> | ||
|
||
<bond-block> ::= <bond> | <bond-block> <newline> <bond> | ||
|
||
<mds> ::= <substrate> <nl> | ||
<author> <nl> | ||
<description> <nl> | ||
<atom-block> <nl> | ||
<bond-block> (<nl><eof>|<eof>) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main deviation I have made is here. Both
<newline> △ <character>
and<set of all valid utf8>
(I should addcodepoints
to that text) are shortcuts, but otherwise we need to define our<string>
class by including EVERY character we want to be valid in this file. Even with just lower and uppercase ascii that will add clutter, but if we want to make sure that Asian, Arabic, Jewish, etc... authors can add their real given name to MDS files, then the grammar should include more than ascii. Defining such a class without shortcuts would mean a seriously long class definition where we would need to include all of the characters (many have to be represented as strings, since they are multibyte).NB. Multibyte strings don't break the C or ascii rules, so allowing all utf8 codepoints doesn't require any changes in your code (probably).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the massive class definitions that would be in the file without the Set based shortcuts I think it would be harder to implement parsers. At least, to make it easier we would need comments explaining what the giant right side content is, so we would essentially have some ad hoc implementation of these shortcuts as informal comments. Anyway, I just thought this perspective would help us think about it. If you think the current approach is fine, then I guess we have no issue. I will work on a formalization for the MDM files in whatever free time I get this week ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep it that way then. No need to be 100% BNF compliant.
I tried to explore other ways this evening, it's just not worth it. Your current implementation is good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case we want anything from the established extended BNFs https://en.m.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form