Re: [Boa Users] Difference and match(string, string) and string == string

28 views
Skip to first unread message

Hoan Nguyen

unread,
Mar 21, 2017, 3:39:53 PM3/21/17
to boa-...@googlegroups.com
== checks if 2 strings are identical

match search for a match of the regular expression in the first argument within the second argument.

If you want to check if a file name is AndroidManifest.xml or not, I would say go with ==.


On Tue, Mar 21, 2017 at 2:01 PM, Marcus Adriano <marcusadri...@gmail.com> wrote:

Hi guys,

I'm newer here and I'm research around Android Projects, so what is the difference between these code:

the first:

p: Project = input;
isAndroidProject := false;
count: output sum of int;

visit(p, visitor{
     
        before rev: Revision -> {
              exists(i:int; "AndroidManifest.xml" == rev.files[i].name) {
                    test[p.name] << rev.files[i].name + " | " + rev.log;
                   isAndroidProject = true;
                       stop;
          }
              stop;
  }
     
        before cr: CodeRepository -> {
         foreach (i:int; def(cr.revisions[i]))
                  visit(cr.revisions[i]);
               
                if (!isAndroidProject)
                 stop;
                 
                count << 1;
            snapshot := getsnapshot(cr, "SOURCE_JAVA_JLS");
        foreach (i:int; def(snapshot[i]))
                      visit(snapshot[i]);
            stop;
  }
});

the second:

p: Project = input;
isAndroidProject := false;
count: output sum of int;

visit(p, visitor{
     
        before rev: Revision -> {
              exists(i:int; match("AndroidManifest.xml", rev.files[i].name)) {
                    test[p.name] << rev.files[i].name + " | " + rev.log;
                   isAndroidProject = true;
                       stop;
          }
              stop;
  }
     
        before cr: CodeRepository -> {
         foreach (i:int; def(cr.revisions[i]))
                  visit(cr.revisions[i]);
               
                if (!isAndroidProject)
                 stop;
                 
                count << 1;
            snapshot := getsnapshot(cr, "SOURCE_JAVA_JLS");
        foreach (i:int; def(snapshot[i]))
                      visit(snapshot[i]);
            stop;
  }
});

NOTE: the difference is the "match" and "==" to compare the file in the revision is a AndroidManifest.xml file. 

Which of these codes is the best for the answer "Number of Android Projects on GitHub?"?

--
More information about Boa: http://boa.cs.iastate.edu/
---
You received this message because you are subscribed to the Google Groups "Boa Language and Infrastructure User Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to boa-user+unsubscribe@googlegroups.com.
To post to this group, send email to boa-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Robert E Dyer

unread,
Mar 21, 2017, 3:43:36 PM3/21/17
to boa-...@googlegroups.com
Hoan is exactly right.  If the filename is actually ‘SomeAndroidManifest.xml’ then match() would return true, while the == would return false.

So if you want exact match, use == always.

- Robert

To unsubscribe from this group and stop receiving emails from it, send an email to boa-user+u...@googlegroups.com.

To post to this group, send email to boa-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

________________________________________________
Robert Dyer | Assistant Professor | Department of Computer Science
BGSU | rd...@bgsu.edu | 419.372.3469 | 244 Hayes | Bowling Green, OH

Want to mine ultra-large-scale software repositories with minimal initial
investment? Check out Boa! http://boa.cs.iastate.edu/

Reply all
Reply to author
Forward
0 new messages