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

Allow redundant verbs in a single Verb directive #296

Open
erkyrath opened this issue Jul 23, 2024 · 4 comments
Open

Allow redundant verbs in a single Verb directive #296

erkyrath opened this issue Jul 23, 2024 · 4 comments

Comments

@erkyrath
Copy link
Contributor

PunyInform has the line

Verb 'pronoun' 'pronouns' * -> Pronouns;

This now throws an error in v3 because the verbs collide:

Error: Two different verb definitions refer to "pronoun"

If it were on two lines, it would only be a warning:

Verb 'pronoun' * -> Pronouns;
Verb 'pronouns' * -> Pronouns;

Warning: This verb definition refers to "pronoun", which has already been defined. Use "Extend last" instead.

(If you use "Extend last" then there's no warning at all, but you get a redundant line in the grammar table.)

Arguably the single-line form should be accepted without even a warning. Just ignore the redundant verb word.

@erkyrath
Copy link
Contributor Author

Puny is fixing this with an #IFV5, so it's not an urgent problem:

Verb 'pronoun' * -> Pronouns;
#IFV5;
Verb 'pronouns' * -> Pronouns;
#ENDIF;

@heasm66
Copy link
Contributor

heasm66 commented Dec 13, 2024

As I see it, a check if the returned dictword is a synonym to an already procesed dictword it could be ignored in the while-loop in verbs..make_verb().

    while ((token_type == DQ_TT) || (token_type == SQ_TT))
    {
        int wordlen, textpos, dictword, evnum;
        char *tmpstr;

        int flags = VERB_DFLAG
            + (DICT_TRUNCATE_FLAG ? NONE_DFLAG : TRUNC_DFLAG)
            + (meta_verb_flag ? META_DFLAG : NONE_DFLAG);
        dictword = dictionary_add(token_text, flags, 0, 0);

        evnum = find_verb_entry(dictword);
        if (evnum >= 0)
       {
       .
       .
       .
       }

It's easy to check against the previous dictword, but I would like to check the whole line for synonyms. How do one do that? In a language with a heap and GC I would have stored all returned values in a hash-collection and check against this collection if the dictword is a synonym, but in C/C++?

@erkyrath
Copy link
Contributor Author

Just gotta compare against every item in the list: English_verbs[first_given_verb] to English_verbs[English_verbs_count-1].

@heasm66
Copy link
Contributor

heasm66 commented Dec 14, 2024

One suggestion:

@@ -1279,6 +1279,16 @@ extern void make_verb(void)
            + (meta_verb_flag ? META_DFLAG : NONE_DFLAG);
        dictword = dictionary_add(token_text, flags, 0, 0);

        /* Check if dictword is a synonym and can be ignored on this 
           line (case pronoun/pronouns in z3). */
        int synonym = FALSE;
        for (ix = first_given_verb; ix < English_verbs_count; ix++)
            if (dictword == English_verbs[ix].dictword) synonym = TRUE;
        if (synonym == TRUE) {
            get_next_token();
            continue;
        }

        evnum = find_verb_entry(dictword);
        if (evnum >= 0)
        {

But I think that this is a case where it's justified to use goto, so suggestion2:

@@ -1279,6 +1279,11 @@ extern void make_verb(void)
            + (meta_verb_flag ? META_DFLAG : NONE_DFLAG);
        dictword = dictionary_add(token_text, flags, 0, 0);

        /* Check if dictword is a synonym and can be ignored on this 
           line (case pronoun/pronouns in z3). */
        for (ix = first_given_verb; ix < English_verbs_count; ix++)
            if (dictword == English_verbs[ix].dictword) goto NextIteration;

        evnum = find_verb_entry(dictword);
        if (evnum >= 0)
        {


@@ -1342,6 +1347,7 @@ extern void make_verb(void)
        English_verbs[English_verbs_count].dictword = dictword;
        English_verbs_count++;
        
    NextIteration:
        firsttime = FALSE;
        get_next_token();
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants