Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

please insert also perl and PCRE #190

Closed
faustfa opened this issue Jan 12, 2022 · 3 comments
Closed

please insert also perl and PCRE #190

faustfa opened this issue Jan 12, 2022 · 3 comments
Labels
New language Add a language to the generator stale Old and probably outdated.

Comments

@faustfa
Copy link

faustfa commented Jan 12, 2022

Hi can you insert also Syntax language for PERL and PCRE and PCRE2 and classical C the world would reward you , and i too thanks so much for your big work

@faustfa faustfa added the New language Add a language to the generator label Jan 12, 2022
@noxone
Copy link
Owner

noxone commented Jan 16, 2022

@faustfa : please have a look at #191 whether that C code looks good for you.

@noxone
Copy link
Owner

noxone commented Jan 22, 2022

Hi @faustfa,

if I understand your request correctly, you want to add

  • Perl as a language
  • C as language

Regarding Perl:
It would be great to provide an example of working Perl code using a regex, as I never wrote Perl code yet.

Regarding C:
C using regex.h is handled in #191. But I have more trouble with C using pcre.h as the last time I used C was about 10 years ago and I'm not sure if my code is really correct. My current approach looks like this:

#include "pcre.h"
#include <string.h>

int usePcre(char* textToCheck) {
    /* for pcre_compile */
    pcre* regex;
    const char* error;
    int erroffset;

    /* for pcre_exec */
    int rc;
    int ovector[30];

    /* to get substrings from regex */
    int rc2;
    const char *substring;
    
    /* return value */
    int returnValue = -1;

    regex = pcre_compile("regex", 0, &error, &erroffset, NULL);

    rc = pcre_exec(regex, NULL, textToCheck, (int)strlen(textToCheck), 0, 0, ovector, 30);

    if(rc == PCRE_ERROR_NOMATCH) {
        fprintf(stderr,"no match\n");
        returnValue = 0;
    } else if(rc < -1) {
        fprintf(stderr,"error %d from regex\n",rc);
        returnValue = -2;
    } else {
        returnValue = 1;
    }
    pcre_free(regex);

    return returnValue;
}

Is this code correct? Should something be different? And please provide details on how I can pass the options (multiline, case-insensitive, dot-all) to the regex. Otherwise I'm afraid I cannot add this snippet as I don't know how to generate it.

Thank you!

@noxone
Copy link
Owner

noxone commented May 4, 2022

Hi @faustfa : Please comment on this PR. I have no knowledge how to use Perl and the C-PCRE code above is just a best guess from my side.
I would like you to approve the code or to provide other sample code that I can use.

If there is no reaction on this PR, I will close it soon.

@noxone noxone added the stale Old and probably outdated. label May 7, 2022
@noxone noxone closed this as completed Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New language Add a language to the generator stale Old and probably outdated.
Projects
None yet
Development

No branches or pull requests

2 participants