|
|
Re: Custom end-of-line character, w/ default value. [message #720196 is a reply to message #720186] |
Tue, 30 August 2011 05:25 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi Jack
Selecting any character as EOL seems very flawed, what if you select
"a"? Does that break identifiers?
You use #SET EOL which is very C preprocessor like. If you really want
it, use a two level language so that you get all the pain of that
approach in an at least more predictable fashion.
If you can identify a sensible set of alternative EOLs that do not
conflict, then you can define the grammar for all of them, and use
semantic validation to warn of inconsistent usage.
Regards
Ed Willink
On 30/08/2011 05:52, Jack wrote:
> The language I'm constructing a grammar for, requires the ability to
> change the End-of line character.
>
> For example:
> // By default, end-of line character = ";" int digit;
> digit = 4;
>
> #SET EOL = "." // This sets the End of line character to "." instead
> of ";" int digit2 = 7.
> digit = digit + digit2.
>
> // Note: ";" cannot be used until the following is executed:
> #SET EOL = ";"
>
> I've toyed with the idea some grammar such as this:
> Eol_change:
> '#SET' 'EOL' '=' EOL=STRING;
>
> Statement:
> [var] '=' ([var]|[integer]) [EOL];
>
> This requires me to:
> i) set a default value for EOL, and
> ii) ensure that only one EOL can exist at any time.
>
> I'm not sure how to do this (help please?), and
> (perhaps more importantly) I'm not sure that this is the best way to
> achieve my objective.
>
> Any ideas?
>
>
> Thanks in advance.
>
|
|
|
Re: Custom end-of-line character, w/ default value. [message #720197 is a reply to message #720186] |
Tue, 30 August 2011 05:25 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi Jack
Selecting any character as EOL seems very flawed, what if you select
"a"? Does that break identifiers?
You use #SET EOL which is very C preprocessor like. If you really want
it, use a two level language so that you get all the pain of that
approach in an at least more predictable fashion.
If you can identify a sensible set of alternative EOLs that do not
conflict, then you can define the grammar for all of them, and use
semantic validation to warn of inconsistent usage.
Regards
Ed Willink
On 30/08/2011 05:52, Jack wrote:
> The language I'm constructing a grammar for, requires the ability to
> change the End-of line character.
>
> For example:
> // By default, end-of line character = ";" int digit;
> digit = 4;
>
> #SET EOL = "." // This sets the End of line character to "." instead
> of ";" int digit2 = 7.
> digit = digit + digit2.
>
> // Note: ";" cannot be used until the following is executed:
> #SET EOL = ";"
>
> I've toyed with the idea some grammar such as this:
> Eol_change:
> '#SET' 'EOL' '=' EOL=STRING;
>
> Statement:
> [var] '=' ([var]|[integer]) [EOL];
>
> This requires me to:
> i) set a default value for EOL, and
> ii) ensure that only one EOL can exist at any time.
>
> I'm not sure how to do this (help please?), and
> (perhaps more importantly) I'm not sure that this is the best way to
> achieve my objective.
>
> Any ideas?
>
>
> Thanks in advance.
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06671 seconds