text string with delimiters anchored to the start of a line... #1029
Unanswered
varioustoxins
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi
First of all thanks to the developers I have just developed most of a parser for the STAR format and it seems to have mostly gone swimmingly, but can anyone help me with a problem
As I said I am trying to implement a parser for the STAR format https://pubs.acs.org/doi/10.1021/ci300074v this has multi line strings that are expected to be bound to the start of a line so the following is a multi line string
;
some text
;
but the following isn't because the first ; has a space before it
;
not a string
;
now I can construct these on their own using the following syntax
new_line = _{"\n"}
semi_colon = _{";"}
new_line_semi_colon = @{new_line ~ semi_colon}
line_of_text_only = {char+}
line_of_text_newline = @{line_of_text_only ~ new_line}
line_of_text_new_line_semi_colon = @{line_of_text_only ~ new_line_semi_colon}
line_of_text_newline_or_newline_semi_colon = _{line_of_text_new_line_semi_colon| line_of_text_newline }
semi_colon_bounded_text_string = {new_line_semi_colon ~ line_of_text_newline_or_newline_semi_colon+}
and i can parse the semi_colon_bounded_text_string on its own but as soon as I embed it in a more complex clause its doesn't appear to be recognised, for example
data_value = _{
!key_words
~ non_quoted_text_string
| semi_colon_bounded_text_string
| double_quote_string
| single_quote_string
| frame_code
}
data = {data_name ~ data_value }
I presume this is because of the implicit whitespace rules I have
WHITESPACE = _{ blank | "\n" | "\r" }
any suggestions for a fix (edited)
ah just though of this while typing the above, seems to work...
basic_whitespace = _{ blank | "\n" | "\r" }
WHITESPACE = _{ !new_line_semi_colon ~ basic_whitespace}
is this a good approach?
Beta Was this translation helpful? Give feedback.
All reactions