Skip to content
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

Better document the grammar of the test format #56

Open
gsnedders opened this issue Apr 5, 2015 · 1 comment
Open

Better document the grammar of the test format #56

gsnedders opened this issue Apr 5, 2015 · 1 comment

Comments

@gsnedders
Copy link
Member

We sorta document it as a tree-construction specific format. We should give the generic definition most people use.

It's something like the state machine below:

HEADER: "#([^\n]+)"
BODY: "([^#][^\n]*)"
LF: "\n"

start:
  HEADER -> after_header

after_header:
  LF -> body
  EOF

body:
  LF -> after_lf
  BODY -> body
  EOF

after_lf:
  LF -> after_lf_lf
  BODY -> body
  EOF

after_lf_lf:
  LF -> after_lf_lf {add "\n" to body}
  BODY -> body {add "\n\n" to body}
  HEADER -> after_header
  EOF {add "\n" to body}

This shouldn't be much effort to convert into an LR(2) grammar; the LR(1) grammar equivalent may be hell.

@gsnedders
Copy link
Member Author

Basically what we want, for the terminals above, is:

test = HEADER LF (BODY | LF)*
tests = test (LF LF test)* LF

Which is LR(2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant