main
| Line | |
|---|
| 1 |
|
|---|
| 2 | grammar/OmpLexer.g: defines OpenMP keywords
|
|---|
| 3 | grammar/OmpParser.g: defines OpenMP grammar rules, uses OmpLexer,
|
|---|
| 4 | imports CivlCParser to reuse the rule for expressions
|
|---|
| 5 | antlr2ast.common.OMPPragmaHandler: translating an OpenMP pragma
|
|---|
| 6 | into OpenMP AST nodes. Note: the source is first parsed by the
|
|---|
| 7 | general parser (CivlCParser), and then at the AST builder phase,
|
|---|
| 8 | the OMPPragmaHandler is triggered to translate the OpenMP pragma.
|
|---|
| 9 | The input is a general pragma node produced by applying the general parser
|
|---|
| 10 | (CivlCParser) to the pragma source.
|
|---|
| 11 |
|
|---|
| 12 | - add a new keyword, for example, "barrier"
|
|---|
| 13 | (1) add a token for the keyword in OmpLexer.g: BARRIER: 'barrier';
|
|---|
| 14 | (2) add a case for the keyword in OMPPragmaHandler.markTokens():
|
|---|
| 15 | case "barrier":
|
|---|
| 16 | token.setType(BARRIER);
|
|---|
| 17 | break;
|
|---|
| 18 | Since the OpenMP parser uses extra tokens provided by OmpLexer,
|
|---|
| 19 | it needs to mark those tokens explicitly, which are all
|
|---|
| 20 | considered as "IDENTIFIER" by CivlCParser.
|
|---|
| 21 |
|
|---|
| 22 | - add a new BNF rule
|
|---|
| 23 | (1) add the rule in OmpParser.g
|
|---|
| 24 | (2) add a method for translating the rule in OMPPragmaHandler
|
|---|
| 25 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.