help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unquoted strings in BASIC


From: Maury Markowitz
Subject: Re: Unquoted strings in BASIC
Date: Sun, 1 Dec 2024 21:10:31 -0500

> On Nov 30, 2024, at 8:42 PM, James K. Lowden <jklowden@schemamania.org> wrote:
> I'm just a bit skeptical.  If the rule is that 
> 
>> DATA 10,20,"HELLO,WORLD!"
> and
>> DATA 10,20,HELLO,WORLD!

> Or is it the case that the quoted equivalent would be 
> 
>> DATA 10,20,"HELLO","WORLD!"

This. It's basically CSV, and given the company in question, I'm sure that's 
where MS CVS comes from.

> DATA { yy_push_state(data); }

Is there a difference between yy_push_state(data) and BEGIN(data)?

> then define the start condition and its rules:
> 
> <data>{
>  [[:alpha:]]/[^,\r\n] { /* ... */ return STRING; }
>  [\r]?[\n] { yy_pop_state(); }
> }

There's some syntax here that's new to me. I believe [:alpha:} is only A-Za-z, 
yes? If so that is not correct, as 'one', 'one!' and 'one1' are all valid.

The / I had not seen before. If I understand it correctly it means "the thing 
on the left, but only if it's followed by the one on the right". Is that 
correct? So in this case the string 'one,"two"' would initially match the alpha 
'o' and the continue matching n and e, then stopping because it hit the comma. 
If so, this appears to be what I need, but when I tried it, it never matched. I 
changed [:alpha;] to A-Za-z as maybe the :alpha: was a problem in clang, but 
that didn't match either. For fun I removed the ^, and then did match, but it 
matched only one the 'o', which I *assume* was the trailing o in 'two'.

I had managed to get to this point for testing the conditional states:

<DATA>[^0-9][A-Za-z]*[,:\n] {
            yytext[strlen(yytext) - 1] = '\0';
            yylval.s = str_new(yytext + 1);
            return STRING;
          }

Used on:

10100 DATA "one",two,"three"

It correctly passes "one" and "three" using the normal quoted string rule, but 
when it gets 'two' I get ',two,' (with leading and trailing commas). This means 
it no longer matches the bison rule that has an expression ',' expression. Is 
there a way to "rewind" one character to emit the commas? I think that might do 
it.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]