List Info

Thread: newbie




newbie
country flaguser name
United States
2007-12-13 14:37:33
Can someone tell me why I might get a segfault in yyparse()
at

YYSTYPE *yyvs = yyvsa;

I think it has something to do with

%union
{
   char string[1000000];
}

which works fine with yacc.

Thanks,

Jim
--

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
James Long
Biotechnology Computing Research Group
University of Alaska
jim.long|at|alaska.edu
http://biotech.inbre.
alaska.edu
(907) 474-5769
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%






_______________________________________________
help-bisongnu.org http
://lists.gnu.org/mailman/listinfo/help-bison

Re: newbie
country flaguser name
United States
2007-12-13 19:08:54
I've answered my own question. The requested semantic stack
for string 
[1000000] is too big.

Thanks,

Jim
--

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
James Long
Biotechnology Computing Research Group
University of Alaska
jim.long|at|alaska.edu
http://biotech.inbre.
alaska.edu
(907) 474-5769
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




On Dec 13, 2007, at 11:37 AM, James Long wrote:

> Can someone tell me why I might get a segfault in
yyparse() at
>
> YYSTYPE *yyvs = yyvsa;
>
> I think it has something to do with
>
> %union
> {
>   char string[1000000];
> }
>
> which works fine with yacc.
>
> Thanks,
>
> Jim
> --
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> James Long
> Biotechnology Computing Research Group
> University of Alaska
> jim.long|at|alaska.edu
> http://biotech.inbre.
alaska.edu
> (907) 474-5769
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
>
>
>



_______________________________________________
help-bisongnu.org http
://lists.gnu.org/mailman/listinfo/help-bison

Re: newbie
country flaguser name
Germany
2007-12-14 08:32:11
This subject came up recently.

If I saw this in a parser, I would suspect that it was
malicious code.

It's not just too big, there is no reason for it.  If any
symbol in a 
parser really needed to refer to a string of this size, it
should probably 
be referring to a file instead.

By the way, it would probably be a good idea for you to
choose more 
descriptive subjects.  The subject "newbie" made
me think this was spam 
and I very nearly deleted it.  "[help-bison]" is
not added automatically.

Laurence Finston


On Thu, 13 Dec 2007, James Long wrote:

> I've answered my own question. The requested semantic
stack for
> string[1000000] is too big.
> 
> Thanks,
> 
> Jim
> --
> 
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> James Long
> Biotechnology Computing Research Group
> University of Alaska
> jim.long|at|alaska.edu
> http://biotech.inbre.
alaska.edu
> (907) 474-5769
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> 
> 
> 
> 
> On Dec 13, 2007, at 11:37 AM, James Long wrote:
> 
> >Can someone tell me why I might get a segfault in
yyparse() at
> >
> >YYSTYPE *yyvs = yyvsa;
> >
> >I think it has something to do with
> >
> >%union
> >{
> >  char string[1000000];
> >}
> >
> >which works fine with yacc.
> >
> >Thanks,
> >
> >Jim
> >--
> >
> >%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> >James Long
> >Biotechnology Computing Research Group
> >University of Alaska
> >jim.long|at|alaska.edu
> >http://biotech.inbre.
alaska.edu
> >(907) 474-5769
> >%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> >
> >
> >
> >
> 
> 
> 
> _______________________________________________
> help-bisongnu.org http
://lists.gnu.org/mailman/listinfo/help-bison
> 


_______________________________________________
help-bisongnu.org http
://lists.gnu.org/mailman/listinfo/help-bison

Re: large strings, was Re: newbie
country flaguser name
United States
2007-12-14 17:20:03
Ahh, of course you are right. I need only place a pointer on
the  
stack, not the entire string. Doh!

A little less of a newbie,

Jim
--

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
James Long
Biotechnology Computing Research Group
University of Alaska
jim.long|at|alaska.edu
http://biotech.inbre.
alaska.edu
(907) 474-5769
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




On Dec 14, 2007, at 6:32 AM, James Long wrote:

> Thanks for the feedback. The parser really does need to
refer to  
> large strings, these are descriptions of very large
biological  
> networks with motifs that include thousands of genes,
with  
> potentially tens of thousands total. The parser then
turns them  
> into Systems Biology Markup Language (see http://range.sf.net for  
> code). But I didn't know that the string could be a
file, can you  
> give me a pointer to some documentation for that?
>
> Thanks,
>
> Jim
> --
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> James Long
> Biotechnology Computing Research Group
> University of Alaska
> jim.long|at|alaska.edu
> http://biotech.inbre.
alaska.edu
> (907) 474-5769
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
>
>
> On Dec 14, 2007, at 5:32 AM, Laurence Finston wrote:
>
>> This subject came up recently.
>>
>> If I saw this in a parser, I would suspect that it
was malicious  
>> code.
>>
>> It's not just too big, there is no reason for it. 
If any symbol in a
>> parser really needed to refer to a string of this
size, it should  
>> probably
>> be referring to a file instead.
>>
>> By the way, it would probably be a good idea for
you to choose more
>> descriptive subjects.  The subject
"newbie" made me think this was  
>> spam
>> and I very nearly deleted it. 
"[help-bison]" is not added  
>> automatically.
>>
>> Laurence Finston
>>
>>
>> On Thu, 13 Dec 2007, James Long wrote:
>>
>>> I've answered my own question. The requested
semantic stack for
>>> string[1000000] is too big.
>>>
>>> Thanks,
>>>
>>> Jim
>>> --
>>>
>>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>>> James Long
>>> Biotechnology Computing Research Group
>>> University of Alaska
>>> jim.long|at|alaska.edu
>>> http://biotech.inbre.
alaska.edu
>>> (907) 474-5769
>>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>>>
>>>
>>>
>>>
>>> On Dec 13, 2007, at 11:37 AM, James Long
wrote:
>>>
>>>> Can someone tell me why I might get a
segfault in yyparse() at
>>>>
>>>> YYSTYPE *yyvs = yyvsa;
>>>>
>>>> I think it has something to do with
>>>>
>>>> %union
>>>> {
>>>>  char string[1000000];
>>>> }
>>>>
>>>> which works fine with yacc.
>>>>
>>>> Thanks,
>>>>
>>>> Jim
>>>> --
>>>>
>>>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>>>> James Long
>>>> Biotechnology Computing Research Group
>>>> University of Alaska
>>>> jim.long|at|alaska.edu
>>>> http://biotech.inbre.
alaska.edu
>>>> (907) 474-5769
>>>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
_______________________________________________
>>> help-bisongnu.org http
://lists.gnu.org/mailman/listinfo/help-bison
>>>
>



_______________________________________________
help-bisongnu.org http
://lists.gnu.org/mailman/listinfo/help-bison

Re: large strings, was Re: newbie
country flaguser name
Germany
2007-12-15 04:22:32
> Thanks for the feedback. The parser really does need to
refer to
> large strings, these are descriptions of very large
biological
> networks with motifs that include thousands of genes,
with
> potentially tens of thousands total. The parser then
turns them into
> Systems Biology Markup Language (see http://range.sf.net for
code).
> But I didn't know that the string could be a file, can
you give me a
> pointer to some documentation for that?

I did read your follow-up message, and yes, you can use a
pointer.  The
problem is, for each symbol, you will have a different
pointer.  If you
don't allocate memory for it and dereference it, you will
certainly get
incorrect results and probably a segmentation fault.

I can understand that the code in your actions would need to
refer to long
strings, either in buffers (`char' arrays, C-style strings,
C++ `strings',
or whatever), but I can't think of any reason why the
semantic value of
the symbols in your grammar would need to be of any of these
types.

If there is some reason, a possibility you might want to
consider is to
use `FILE*' or a pointer to a file descriptor as the
semantic value of
your symbols.

I strongly suspect that a better approach would be to pass
an object as a
parameter to `yylex' and `yyparse' which contains pointers
that reference
the files or buffers containing the strings.  This is
documented in the
Bison manual and I have described ways to use it many times
on this list,
if you want to have a search through.

This parameter is passed to `yylex' and `yyparse' in the
form of a pointer
to `void' and must be cast to the correct type in the
actions or in any
functions called in the actions.

In GNU 3DLDF, I use a type called `Scanner_Type', whereby I
usually refer
to the "type" `Scanner_Node', which is simply a
"typedef" for
`Scanner_Type*'.  I call the parameter `parameter'.  You can
find many
examples of it's use in my sources: 
ht
tp://www.gnu.org/software/3dldf/LDF.html#Sources

I use a `class' type, since I use C++, though I do not
generate a C++
parser.  I simply generate a C parser and compile using
`g++'.  If you're
using C, you could use a `struct'.  You could then use an
array, a linked
list, a binary tree, or some other data structure to hold
the pointers to
your character buffers, files, or whatever.

Laurence Finston





_______________________________________________
help-bisongnu.org http
://lists.gnu.org/mailman/listinfo/help-bison

large strings, was Re: newbie
country flaguser name
United States
2007-12-14 09:32:13
Thanks for the feedback. The parser really does need to
refer to  
large strings, these are descriptions of very large
biological  
networks with motifs that include thousands of genes, with 

potentially tens of thousands total. The parser then turns
them into  
Systems Biology Markup Language (see http://range.sf.net for
code).  
But I didn't know that the string could be a file, can you
give me a  
pointer to some documentation for that?

Thanks,

Jim
--

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
James Long
Biotechnology Computing Research Group
University of Alaska
jim.long|at|alaska.edu
http://biotech.inbre.
alaska.edu
(907) 474-5769
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



On Dec 14, 2007, at 5:32 AM, Laurence Finston wrote:

> This subject came up recently.
>
> If I saw this in a parser, I would suspect that it was
malicious code.
>
> It's not just too big, there is no reason for it.  If
any symbol in a
> parser really needed to refer to a string of this size,
it should  
> probably
> be referring to a file instead.
>
> By the way, it would probably be a good idea for you to
choose more
> descriptive subjects.  The subject "newbie"
made me think this was  
> spam
> and I very nearly deleted it.  "[help-bison]"
is not added  
> automatically.
>
> Laurence Finston
>
>
> On Thu, 13 Dec 2007, James Long wrote:
>
>> I've answered my own question. The requested
semantic stack for
>> string[1000000] is too big.
>>
>> Thanks,
>>
>> Jim
>> --
>>
>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>> James Long
>> Biotechnology Computing Research Group
>> University of Alaska
>> jim.long|at|alaska.edu
>> http://biotech.inbre.
alaska.edu
>> (907) 474-5769
>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>>
>>
>>
>>
>> On Dec 13, 2007, at 11:37 AM, James Long wrote:
>>
>>> Can someone tell me why I might get a segfault
in yyparse() at
>>>
>>> YYSTYPE *yyvs = yyvsa;
>>>
>>> I think it has something to do with
>>>
>>> %union
>>> {
>>>  char string[1000000];
>>> }
>>>
>>> which works fine with yacc.
>>>
>>> Thanks,
>>>
>>> Jim
>>> --
>>>
>>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>>> James Long
>>> Biotechnology Computing Research Group
>>> University of Alaska
>>> jim.long|at|alaska.edu
>>> http://biotech.inbre.
alaska.edu
>>> (907) 474-5769
>>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>>>
>>>
>>>
>>>
>>
>>
>>
>> _______________________________________________
>> help-bisongnu.org http
://lists.gnu.org/mailman/listinfo/help-bison
>>




_______________________________________________
help-bisongnu.org http
://lists.gnu.org/mailman/listinfo/help-bison

[1-6]

about | contact  Other archives ( Real Estate discussion Medical topics )