Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/GPDef.atg @ 13828

Last change on this file since 13828 was 10412, checked in by gkronber, 11 years ago

#2026 also support C++-style comments

File size: 2.1 KB
Line 
1/* HeuristicLab
2 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
3 *
4 * This file is part of HeuristicLab.
5 *
6 * HeuristicLab is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * HeuristicLab is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20$namespace=SyntaxAnalyzer
21
22COMPILER GPDefSyntaxAnalyzer
23
24CHARACTERS
25  letter = 'A'..'Z' + 'a'..'z'.
26  digit = '0'..'9'.
27
28TOKENS
29  ident = letter {letter | digit} .
30
31COMMENTS FROM "/*" TO "*/" NESTED
32COMMENTS FROM "//" TO "\r"
33
34IGNORE '\t' + '\r' + '\n'
35
36// grammar production rules in EBNF syntax
37PRODUCTIONS
38  GPDefSyntaxAnalyzer =
39    "PROBLEM" ident
40    ["CODE" "<<" {ANY} ">>" ]
41    ["INIT" "<<" {ANY} ">>" ]
42    "NONTERMINALS" { NonterminalDecl }
43    "TERMINALS" { TerminalDecl }
44    "RULES" { RuleDef }
45    ("MAXIMIZE" | "MINIMIZE") "<<" {ANY} ">>"
46    "END" ident '.'.
47
48
49  SemDecl = "LOCAL" "<<" {ANY} ">>"
50  .
51
52  SemAction = "SEM" "<<" {ANY} ">>"
53  .
54
55  NonterminalDecl = ident [ "<<" {ANY} ">>" ] '.'
56  .
57
58  TerminalDecl = ident [ "<<" {ANY} ">>" ]
59    [ "CONSTRAINTS" ConstraintDef ]
60    '.'
61  .
62
63  ConstraintDef = { ConstraintRule }.
64  ConstraintRule = ident "IN" SetDefinition .
65  SetDefinition =
66    "SET" "<<" {ANY} ">>"
67    | "RANGE" "<<" {ANY} ">>" ".." "<<" {ANY} ">>"
68  .
69
70  RuleDef = ident [ "<<" {ANY} ">>" ] '=' [SemDecl] SynExpr '.'
71  .
72
73  SynExpr = SynTerm { '|' SynTerm }
74  .
75
76  SynTerm = SynFact { SynFact }
77  .
78
79  SynFact =
80    ident [ "<<" {ANY} ">>" ]
81    | "EPS"
82    | '(' SynExpr ')'
83    | '[' SynExpr ']'
84    | '{' SynExpr '}'
85    | SemAction
86  .
87
88END GPDefSyntaxAnalyzer.
Note: See TracBrowser for help on using the repository browser.