-
Notifications
You must be signed in to change notification settings - Fork 2
Description
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:
-
setLang: set the
user_set_langvariable to the language user wants to parse in the future call to parseOpenMP -
getLang: return the value of the
user_set_langvariable -
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_langthat is already set, report error and return. Ifuser_set_langis not set, parser will use the detected language (stored inauto_langvariable) for the parsing and set the directive->lang field. In this case,auto_langwill be set at begining as Lang_C and then will be reset as Lang_C++. The directive->lang will be eitheruser_set_langor 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)