|
|
Re: Supporting unquoted string with spaces [message #1644862 is a reply to message #1644143] |
Mon, 02 March 2015 07:53 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
Seems interesting. I nearly replied to your original message suggesting
that using Xtext for a lexing problem was crazy, but you seem to have a
new way of using Xtext that I do not understand.
Please elaborate on "you will need to split lexer and parser using the a
fragment because text by default use a lexer/parser in the same file".
I'm only aware of grammar splitting by the grammar...with... daisy
chain. I'm not sure which fragment you refer to: both of the existing
AntlrGeneratorFragments, your custom fragment or ...
Regards
Ed Willink
On 01/03/2015 23:35, Luis De Bello wrote:
> Hi guys,
>
> I am replying to my own answer ,maybe this can be useful to others. I
> was able to support unquoted string with spaces, using a custom lexer,
> I enclose my terminals in Xtext and the portion of code of my lexer
>
> Xtext file:
> terminal UNQUOTED_STRING:
> !NON_QUOTED_STRING_START !(NON_QUOTED_STRING_END)*;
>
> terminal fragment NON_QUOTED_STRING_START:
> '"'|"'"|'0'..'9'|'!'|'#'|'$'|'('|')'|'*'|'+'|','|'-'|'.'|'/'|':'|'<'|'='|'>'|'?'|'['|']'|'{'|'}'|'|'|'%'|'^'|'@'|'\r'|'\n'|'
> '|'\t';
>
> terminal fragment NON_QUOTED_STRING_END:
> ('!'|'#'|'$'|'('|')'|'*'|','|'.'|'/'|':'|'<'|'='|'>'|'?'|'['|']'|'{'|'}'|'|'|'%'|'^'|'\r'|'\n');
>
>
> Lexer grammar:
> RULE_UNQUOTED_STRING : {!isKeyword()}?=>
> ~(RULE_NON_QUOTED_STRING_START) ({!isIsolatedKeyword()}?=>
> ~(RULE_NON_QUOTED_STRING_END))*;
>
> The isKeyword and isIsolatedKeyword are two methods implement to check
> for keywords using lookahead functionality it will depend on each
> implementation.
>
> I hope this will be useful for others also ,you will need to split
> lexer and parser using the a fragment because text by default use a
> lexer/parser in the same file.
>
> Regards,
> Luis
|
|
|
|
Powered by
FUDForum. Page generated in 0.02320 seconds