Menu

#19 brackets confusing the parser

Moritz_2_0_1
closed
None
3
2021-09-22
2020-12-28
No

Hi Eckard,

I identified, that brackets can confuse the C parser
Code like this

int test(void){
  int16_t s16ok  = (int16_t) 0;
  int16_t s16nok = ((int16_t) 0);
  return 0;
}

breaks when it comes to the second variable
BR
Wasili

Discussion

  • Eckard Klotz

    Eckard Klotz - 2020-12-28
    • status: open --> accepted
     
  • Eckard Klotz

    Eckard Klotz - 2020-12-29

    Hello Wasili.

    To solve this issue I have to provide a new configuration file. This patch should should solve your issue " brackets confusing the parser ".

    • Please check the attached file with your virus scanner before you use it to replace the one with the same name in the bin folder of your Moritz distribution.
    • Replace with the attached file "ANSI_C_Source_C_only_grm.a2x" the one with the same name in your Moritz distribution sub folder "[MoritzRoot]\LangPack\ansi_c\a2x\".
    • It may be useful to keep the old files for the case that the new ones are not satisfying you.

    Note this patch was created for the newest Moritz patch published on 2020-12-23 together with the patch I have provided to solve your issue struct initializer with condition and was not tested with older versions.

    • If you face additional issues related to this topic please update your Moritz release by using the patch as described in the readme.

    The patch, I provide here, is extending the syntax-rules initializer and expr_stmt.

    • The extension of the initializer rule is directly associated with the parsing issue reported by you.
    • The extension of the rule expr_stmt modifies the resulting xml-result to ensure that the diagram generation is treating the whole assignment-expression in your code-line as one as one command. (I think this is fixing an additional that I recognized while evaluating your example)

    Please check this patch and respond with a comment if your issue is solved or not.

    Have a happy new year.

    Stay healthy,
    Eckard.

     

    Last edit: Eckard Klotz 2020-12-29
  • Eckard Klotz

    Eckard Klotz - 2020-12-29
    • status: accepted --> pending
     
  • Eckard Klotz

    Eckard Klotz - 2021-09-22
    • status: pending --> closed
     

Log in to post a comment.