1) [:space:] is a character class expression. If you want one or more
spaces you would do [[:space:]]+. What your scanner is looking for right
now is one of either ":, s, p, a, c, or e". Does that make sense? Just wrap
it in another set of []'s
2) . only matches newline, the documentation is not
Peng Yu,
Why Bison/Flex are not good at Fortran? What is special for Fortran's grammar?
Parsing Fortran is not that hard it is the lexical analysis that
is very fiddly. Read about my recent attempts here:
shape-of-code.coding-guidelines.com/2009/12/parsing-fortran-95
--
Derek M. Jones
On 29 Dec 2009, at 03:54, Peng Yu wrote:
It seems to me that to use bison I have to have a BNF first. I'm
reading Programming Language Pragmatics 3rd Ed (PLP3). What is not
clear to me is that how to construct the BNF for a language? Based on
my reading of PLP3, I haven't found a formal way to c
On Wed, Dec 30, 2009 at 12:54 AM, Marcel Laverdet wrote:
>
>
> 1) [:space:] is a character class expression. If you want one or more
> spaces you would do [[:space:]]+. What your scanner is looking for right
> now is one of either ":, s, p, a, c, or e". Does that make sense? Just wrap
> it in anot
> Do you actually mean '.' matches non newline?
Yes, apologies :)
> I made some corrections. Now yylval_string.l becomes the following. You
said yyerror should not be used in the flex file. I'm wondering what I
should use to replace the line '. { yyerror("mystery character %c\n",
*yytext)
On Wed, Dec 30, 2009 at 1:05 PM, Marcel Laverdet wrote:
>
>
>> Do you actually mean '.' matches non newline?
>
> Yes, apologies :)
>
>> I made some corrections. Now yylval_string.l becomes the following. You
> said yyerror should not be used in the flex file. I'm wondering what I
> should use to r
You don't change the BNF. The idea is that it's an unexpected token and
should never come up. If it does come up you've got a problem.
Really you're best off making your scanner be able to handle ALL input no
matter what.
On Wed, 30 Dec 2009 21:52:46 -0600, Peng Yu wrote:
> On Wed, Dec 30, 200
I want to get words from a file and print them out. But I'm not sure
how to make yylval a pointer to the string yytext. Could somebody let
me know how to modify the following code so that the string can be
retrieved the symbol WORD.
>yylval_string.l
%option nodefault
%{
# include "yylval_string.ta
On 31/12/2009 05:11, Peng Yu wrote:
I want to get words from a file and print them out. But I'm not sure
how to make yylval a pointer to the string yytext. Could somebody let
me know how to modify the following code so that the string can be
retrieved the symbol WORD.
yylval_string.l