k-user AT lists.cs.illinois.edu
Subject: K-user mailing list
List archive
- From: Eric Huber <echuber2 AT illinois.edu>
- To: k-user AT lists.cs.illinois.edu
- Subject: [[K-user] ] Differences between Token and Lexer
- Date: Fri, 27 May 2016 00:44:16 -0500
Hi, I'm wondering if I understand correctly the differences between Token and Lexer. Lexer is not greedy, so it must be given the follow rule with -/- to show when it may NOT stop collecting characters for one token, correct? Whereas Token is greedy and can not use -/- rules.
Also, this detail from ref-manual.k seems counter-intuitive:
The construction {<char set> "<separator>"}+ will match 'A', 'A-A',
'A-A-A', but not 'A-'.
Doesn't the syntax suggest that the separator character must follow each character? I take it that the only reason this works is because in the particular example:
syntax MODNAME ::= Lexer{"#"?{[a-z0-9A-Z\_]+ "-"}+}
syntax MODNAME -/- [a-z0-9A-Z\-\_]
it is using Lexer with the construction, so it is not a greedy selection, and the follow exclusion rule says that - may not appear at the end. But the line in the documentation makes it sound like a special construction to specify ranges with a separator.
Thank you,
Eric Huber
Also, this detail from ref-manual.k seems counter-intuitive:
The construction {<char set> "<separator>"}+ will match 'A', 'A-A',
'A-A-A', but not 'A-'.
Doesn't the syntax suggest that the separator character must follow each character? I take it that the only reason this works is because in the particular example:
syntax MODNAME ::= Lexer{"#"?{[a-z0-9A-Z\_]+ "-"}+}
syntax MODNAME -/- [a-z0-9A-Z\-\_]
it is using Lexer with the construction, so it is not a greedy selection, and the follow exclusion rule says that - may not appear at the end. But the line in the documentation makes it sound like a special construction to specify ranges with a separator.
Thank you,
Eric Huber
- [[K-user] ] Differences between Token and Lexer, Eric Huber, 05/27/2016
- Re: [[K-user] ] Differences between Token and Lexer, Radu Mereuta, 05/30/2016
- Re: [[K-user] ] Differences between Token and Lexer, Eric Huber, 05/30/2016
- Re: [[K-user] ] Differences between Token and Lexer, Radu Mereuta, 05/30/2016
- Re: [[K-user] ] Differences between Token and Lexer, Eric Huber, 05/30/2016
- Re: [[K-user] ] Differences between Token and Lexer, Radu Mereuta, 05/30/2016
Archive powered by MHonArc 2.6.16.