CoCo--Related question 
Author Message
 CoCo--Related question



Quote:

> Hello all,

> I am currently trying to build a compiler with the help of CoCo, but
> there are some tricky things to solve yet. One thing: My compiler
> should be able to parse, amongst other things, arbitrary text enclosed
> by quotes or double quotes. In my current CoCo description of the
> compiler this is possible for all sorts of strings that do not contain
> blanks.

> I have read in the documentation that CoCo ignores blanks by default,
> but I need to work with strings containing blanks in some places. Is
> there any way to do it, or do I have to split up the strings into
> separate units, which will only solve part of my problem?

> Thanks for Your help,

>                 Harald

Hello.

I'm a little bit confused by your question.  Are you talking about
blanks as in spaces or blanks as in blank lines?  Coco should
definitely handle spaces without any problem.

This from the grammar defining the Coco compiler :

CHARACTERS
  noQuote1 = ANY - '"' - eol.
  noQuote2 = ANY - "'" - eol.

IGNORE eol + tab + CHR(28)

TOKENS
  string   = '"' {noQuote1} '"' | "'" {noQuote2} "'".

So Coco can't directly handle quoted strings that span more than
one line, but it should be able to handle strings that contain
spaces.  I suppose one could add some type of string concatenation
into the Coco ATG.  I hope this helps.

--
Guns don't kill people...bullets do.

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sun, 02 Mar 2003 03:00:00 GMT  
 CoCo--Related question

Hello all,

I am currently trying to build a compiler with the help of CoCo, but
there are some tricky things to solve yet. One thing: My compiler
should be able to parse, amongst other things, arbitrary text enclosed
by quotes or double quotes. In my current CoCo description of the
compiler this is possible for all sorts of strings that do not contain
blanks.

I have read in the documentation that CoCo ignores blanks by default,
but I need to work with strings containing blanks in some places. Is
there any way to do it, or do I have to split up the strings into
separate units, which will only solve part of my problem?

Thanks for Your help,

                Harald

--
Harald Wagener                        Uni Bremen, Fb3 -- Informatik

Tel: +49 421 2184216                         Mobil: +49 174 7530012



Mon, 03 Mar 2003 00:29:00 GMT  
 CoCo--Related question

Quote:
>> > I have read in the documentation that CoCo ignores blanks by default,
> > but I need to work with strings containing blanks in some places. Is
> > there any way to do it, or do I have to split up the strings into
> > separate units, which will only solve part of my problem?

> > Thanks for Your help,

> >                 Harald

> Hello.

> I'm a little bit confused by your question.  Are you talking about
> blanks as in spaces or blanks as in blank lines?  Coco should
> definitely handle spaces without any problem.

I am talking about spaces. Problem is: I copied the parts You referred
to directly, but nonetheless, the resulting parser barfs on strings
containing spaces, such as "blank ". Thanks for Your help, anyways
                                 ^

--
Harald Wagener                        Uni Bremen, Fb3 -- Informatik

Tel: +49 421 2184216                         Mobil: +49 174 7530012



Mon, 03 Mar 2003 03:00:00 GMT  
 CoCo--Related question
Quote:
> I am talking about spaces. Problem is: I copied the parts You referred
> to directly, but nonetheless, the resulting parser barfs on strings
> containing spaces, such as "blank ". Thanks for Your help, anyways

                                  ^
In the grammars that it accepts (ie the .ATG files) Coco is set to
ignore white space between tokens, and not to allow them within tokens.
So something like this in a production

     FuncHead = "void main () {" bodyOfFunction "}" .

is not allowed - you have to write it

     FuncHead = "void" "main" "(" ")" bodyOfFunction "}" .

which creates a parser that (correctly) allows any number of spaces to
appear between
void and main and main and ( etc, not just one space.  That is, the
literal tokens in an ATG file may not contain spaces.

If you want to fudge this you can.  For example, try

CHARACTERS
   sp = " ";
   letter = "abcdefghijklmnopqrstuvwxyz" .
TOKENS
   MyToken = '"' { letter | sp } '"' .

will do the trick for you, withot being caught as you would be if you
wrote

   MyToken = '"' { letter | " " } '"' .

Is this a solution to your problem?  

The definition of a string given by an earlier poster for a general
string:

CHARACTERS
  noQuote1 = ANY - '"' - eol.
  noQuote2 = ANY - "'" - eol.

IGNORE eol + tab + CHR(28)

TOKENS
  string   = '"' {noQuote1} '"' | "'" {noQuote2} "'".

is quite correct ansd is the one used in Coco itself, but there is a
semantic check within Coco that the strings used as literals within the
productions contain no spaces. You don't have to embed such a semantic
check into your own grammar, of course.



Mon, 03 Mar 2003 03:00:00 GMT  
 CoCo--Related question
I cannot imagine that CoCo ignores blanks within strings.
It will treat blanks inside strings exactly like any other character.
I guess, CoCo will ignore white space between tokens, but not inside strings.

- josef

Quote:

> Hello all,

> I am currently trying to build a compiler with the help of CoCo, but
> there are some tricky things to solve yet. One thing: My compiler
> should be able to parse, amongst other things, arbitrary text enclosed
> by quotes or double quotes. In my current CoCo description of the
> compiler this is possible for all sorts of strings that do not contain
> blanks.

> I have read in the documentation that CoCo ignores blanks by default,
> but I need to work with strings containing blanks in some places. Is
> there any way to do it, or do I have to split up the strings into
> separate units, which will only solve part of my problem?

> Thanks for Your help,

>                 Harald

> --
> Harald Wagener                        Uni Bremen, Fb3 -- Informatik

> Tel: +49 421 2184216                         Mobil: +49 174 7530012



Mon, 03 Mar 2003 03:00:00 GMT  
 CoCo--Related question

Quote:

> I cannot imagine that CoCo ignores blanks within strings.
> It will treat blanks inside strings exactly like any other character.
> I guess, CoCo will ignore white space between tokens, but not inside strings.

> - josef

It might all be my fault, after all. I use the same definition for
quote-enclosed strings as in CR.ATG, but when I try parsing the test
file, the parser quits ungraceful when parsing the first string
containing a space (as in "Knoten ").
                                 ^

I find this confisung as Coco itself apparently is working and does
not have this problem. So it must be some other part that's confusing
Coco. I wil look further into this and thank You all for Your help.

H.
--
Harald Wagener                        Uni Bremen, Fb3 -- Informatik

Tel: +49 421 2184216                         Mobil: +49 174 7530012



Tue, 04 Mar 2003 03:00:00 GMT  
 CoCo--Related question
Hmmm, may be you should contact the author (H.M?ssenb?ck)
from the University of Linz.

- josef

Quote:


> > I cannot imagine that CoCo ignores blanks within strings.
> > It will treat blanks inside strings exactly like any other character.
> > I guess, CoCo will ignore white space between tokens, but not inside strings.

> > - josef

> It might all be my fault, after all. I use the same definition for
> quote-enclosed strings as in CR.ATG, but when I try parsing the test
> file, the parser quits ungraceful when parsing the first string
> containing a space (as in "Knoten ").
>                                  ^

> I find this confisung as Coco itself apparently is working and does
> not have this problem. So it must be some other part that's confusing
> Coco. I wil look further into this and thank You all for Your help.

> H.
> --
> Harald Wagener                        Uni Bremen, Fb3 -- Informatik

> Tel: +49 421 2184216                         Mobil: +49 174 7530012



Sat, 08 Mar 2003 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. COCO/P: Looking for COCO Applications

2. NT related question (not really Python related)

3. a short cut related question in awk

4. few questions mac related

5. Help related question

6. CAD graphics / mouse event related question

7. SearchFlash Related File Question

8. RelationManager related question

9. RELATE Class Question

10. CW4.0 - more date related function questions

11. TXA related question

12. Two graph-related questions

 

 
Powered by phpBB® Forum Software