Note that there are some explanatory texts on larger screens.

plurals
  1. POA space is needed to let line_terminator be recognized
    primarykey
    data
    text
    <p>In my <code>lexer.mll</code> I have declared <code>EOS</code> as follows:</p> <pre><code>let line_feed = '\n' (* %x200A *) let carriage_return = '\r' (* %x200D *) let line_terminator = line_feed | carriage_return | carriage_return line_feed (* KO: %x2028 | %x2029 *) let LINE_END = line_terminator let tab_character = '\x09' (* CHARACTER TABULATION *) let eom_character = '\x19' (* END OF MEDIUM *) let space_character = '\x20' (* SPACE *) let underscore = '\x5F' (* LOW LINE or SPACING UNDERSCORE *) let WSC = tab_character | eom_character | space_character let line_continuation = WSC* underscore WSC* line_terminator let WS = (WSC | line_continuation)+ let EOL = WS? LINE_END let EOS = EOL* rule token = parse | WS { token lexbuf } | LINE_END { newline lexbuf; token lexbuf } | EOS { EOS } </code></pre> <p>In my <code>parser.mly</code>, I have something like this:</p> <pre><code>%token EOS ... %% nonterminal : statement EOS statement { semantic-action } </code></pre> <p>I edit my <code>test_KO.txt</code> under <code>Emacs</code> as follows, it raises an error while parsing:</p> <pre><code>a_statement b_statement </code></pre> <p>However, if I add one <code>space</code> after <code>a_statement</code> as follows, it passes the parsing:</p> <pre><code>a_statement(space) b_statement </code></pre> <p>I guess the reason is <code>line_terminator</code> cannot be recognized for <code>test_KO.txt</code>, though <code>a_statemnt</code> and <code>b_statement</code> are not in the same line; <code>line_terminator</code> can be recognized if there is one <code>space</code> between them.</p> <p>Do you think adding <a href="http://www.fileformat.info/info/unicode/char/2028/index.htm" rel="nofollow">x2028</a> and <a href="http://www.fileformat.info/info/unicode/char/2029/index.htm" rel="nofollow">x2029</a> to <code>line_terminator</code> would solve the problem? As <code>ocamllex</code> probably does not support well unicode, it would be complicated to test it...</p> <p>Otherwise, is there any other solution for the problem?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload