passlab / ompparser

ompparser: A Standalone and Unified OpenMP Parser
https://github.com/passlab/ompparser
Other
5 stars 1 forks source link

ompparser APIs #83

Open yanyh15 opened 4 years ago

yanyh15 commented 4 years ago

We need two internal global variables for language: user_set_lang for storing user-specified language, auto_lang for storing parser detected language. Our only report errors that are incompatible.

Now we have three APIs:

  1. setLang: set the user_set_lang variable to the language user wants to parse in the future call to parseOpenMP

  2. getLang: return the value of the user_set_lang variable

  3. parseOpenMP: check the language for the string to be parsed (we can only detect C/C++ and Fortran, we cannot differentiate C and C++), if it is not compatible (C and C++ are compatible) with the user_set_lang that is already set, report error and return. If user_set_lang is not set, parser will use the detected language (stored in auto_lang variable) for the parsing and set the directive->lang field. In this case, auto_lang will be set at begining as Lang_C and then will be reset as Lang_C++. The directive->lang will be either user_set_lang or the detected 'auto_lang'.

For linear clause, detecting language needs to be done at the beginning for C/Fortran and then in the middle of parsing as well since only some modifier are allowed for C++. So if C++ modifier is parsed, parser needs to set auto_lang to C++ if the current auto_lang is not lang_fortran, parser also needs to check whether user_set_langis set and if so, compare it withauto_lang`.

A macro for checking whether detected language matches user-specified language.

#define lang_not_match ( ) (user_set_lang != Lang_unknown && user_set_lang != auto_lang)