Browse Source

Initial source import

tags/v0.1.0
jubianchi 3 years ago
parent
commit
6213f002cf
9 changed files with 384 additions and 0 deletions
  1. 3
    0
      .gitignore
  2. 3
    0
      CHANGELOG.md
  3. 30
    0
      LICENSE.md
  4. 41
    0
      coffeelint.json
  5. 156
    0
      grammars/pp.cson
  6. 16
    0
      package.json
  7. 6
    0
      settings/hoa-compiler-plugin.cson
  8. 33
    0
      styles/hoa-compiler-plugin.less
  9. 96
    0
      test.pp

+ 3
- 0
.gitignore View File

@@ -0,0 +1,3 @@
1
+.DS_Store
2
+npm-debug.log
3
+node_modules

+ 3
- 0
CHANGELOG.md View File

@@ -0,0 +1,3 @@
1
+## 0.1.0 - First Release
2
+* Every feature added
3
+* Every bug fixed

+ 30
- 0
LICENSE.md View File

@@ -0,0 +1,30 @@
1
+Hoa
2
+
3
+
4
+New BSD License
5
+
6
+Copyright © 2007-2015, Hoa community. All rights reserved.
7
+
8
+Redistribution and use in source and binary forms, with or without
9
+modification, are permitted provided that the following conditions are met:
10
+
11
+* Redistributions of source code must retain the above copyright
12
+  notice, this list of conditions and the following disclaimer.
13
+* Redistributions in binary form must reproduce the above copyright
14
+  notice, this list of conditions and the following disclaimer in the
15
+  documentation and/or other materials provided with the distribution.
16
+* Neither the name of the Hoa nor the names of its contributors may be
17
+  used to endorse or promote products derived from this software without
18
+  specific prior written permission.
19
+
20
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
24
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+POSSIBILITY OF SUCH DAMAGE.

+ 41
- 0
coffeelint.json View File

@@ -0,0 +1,41 @@
1
+{
2
+    "max_line_length": {
3
+        "level": "ignore"
4
+    },
5
+    "no_empty_param_list": {
6
+        "level": "error"
7
+    },
8
+    "arrow_spacing": {
9
+        "level": "error"
10
+    },
11
+    "no_interpolation_in_single_quotes": {
12
+        "level": "error"
13
+    },
14
+    "no_debugger": {
15
+        "level": "error"
16
+    },
17
+    "prefer_english_operator": {
18
+        "level": "error"
19
+    },
20
+    "colon_assignment_spacing": {
21
+        "spacing": {
22
+            "left": 0,
23
+            "right": 1
24
+        },
25
+        "level": "error"
26
+    },
27
+    "braces_spacing": {
28
+        "spaces": 1,
29
+        "level": "error"
30
+    },
31
+    "spacing_after_comma": {
32
+        "level": "error"
33
+    },
34
+    "no_stand_alone_at": {
35
+        "level": "error"
36
+    },
37
+    "indentation": {
38
+        "level": "error",
39
+        "value": 4
40
+    }
41
+}

+ 156
- 0
grammars/pp.cson View File

@@ -0,0 +1,156 @@
1
+# Hoa
2
+#
3
+#
4
+# New BSD License
5
+#
6
+# Copyright © 2007-2015, Hoa community. All rights reserved.
7
+#
8
+# Redistribution and use in source and binary forms, with or without
9
+# modification, are permitted provided that the following conditions are met:
10
+#     * Redistributions of source code must retain the above copyright
11
+#       notice, this list of conditions and the following disclaimer.
12
+#     * Redistributions in binary form must reproduce the above copyright
13
+#       notice, this list of conditions and the following disclaimer in the
14
+#       documentation and/or other materials provided with the distribution.
15
+#     * Neither the name of the Hoa nor the names of its contributors may be
16
+#       used to endorse or promote products derived from this software without
17
+#       specific prior written permission.
18
+#
19
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
23
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
+# POSSIBILITY OF SUCH DAMAGE.
30
+
31
+'scopeName': 'source.hoa.compiler.pp'
32
+'name': 'Hoa Compiler PP'
33
+'fileTypes': [
34
+    'pp'
35
+]
36
+'firstLineMatch': '^%(?:skip|token)\\b'
37
+'foldingStartMarker': '^(?:#?\w+:|//)'
38
+'foldingStopMarker': '^$'
39
+'patterns': [
40
+    { 'include': '#punctuation' }
41
+    { 'include': '#comment' }
42
+    { 'include': '#skip' }
43
+    { 'include': '#token' }
44
+    { 'include': '#node' }
45
+    { 'include': '#rule' }
46
+    { 'include': '#token_capture' }
47
+    { 'include': '#token_nocapture' }
48
+    { 'include': '#rule_call' }
49
+    { 'include': '#node_call' }
50
+]
51
+'repository':
52
+    'punctuation':
53
+        'captures':
54
+            '1':
55
+                'name': 'punctuation'
56
+        'match': '(\\*|\\+|\\?|\\||->|\\(|\\)|\\{|\\}|\\[|\\])'
57
+
58
+    'comment':
59
+        'captures':
60
+            '1':
61
+                'name': 'line.comment'
62
+        'match': '^(//.*)$'
63
+
64
+    'skip':
65
+        'captures':
66
+            '1':
67
+                'name': 'skip.line'
68
+            '2':
69
+                'name': 'skip.keyword'
70
+            '3':
71
+                'name': 'skip.constant.name'
72
+            '4':
73
+                'name': 'skip.string.value'
74
+        'match': '^((%skip)\\s+([^\\s]+)\\s+([^\\s]+))'
75
+
76
+    'token':
77
+        'captures':
78
+            '1':
79
+                'name': 'token.line'
80
+            '2':
81
+                'name': 'keyword'
82
+            '3':
83
+                'name': 'string.namespace'
84
+            '4':
85
+                'name': 'punctuation'
86
+            '5':
87
+                'name': 'constant.name'
88
+            '6':
89
+                'name': 'string.value'
90
+            '7':
91
+                'name': 'punctuation'
92
+            '8':
93
+                'name': 'string.namespace'
94
+        'match': '^((%token)\\s+(?:([^\\s]+)(::))?([^\\s]+)\\s+([^\\s]+)\\s+(?:(->)\\s+([^\\s]+))?)'
95
+
96
+    'node':
97
+        'captures':
98
+            '1':
99
+                'name': 'node.line'
100
+            '2':
101
+                'name': 'variable.name'
102
+            '3':
103
+                'name': 'punctuation'
104
+        'match': '^((#\\w+)(:))'
105
+
106
+    'rule':
107
+        'captures':
108
+            '1':
109
+                'name': 'rule.line'
110
+            '2':
111
+                'name': 'variable.name'
112
+            '3':
113
+                'name': 'punctuation'
114
+        'match': '^((\\w+)(:))'
115
+
116
+    'token_capture':
117
+        'captures':
118
+            '1':
119
+                'name': 'token.capture'
120
+            '2':
121
+                'name': 'punctuation'
122
+            '3':
123
+                'name': 'constant.name'
124
+            '4':
125
+                'name': 'punctuation'
126
+        'match': '((<)([^\\s>]+)(>))'
127
+
128
+    'token_nocapture':
129
+        'captures':
130
+            '1':
131
+                'name': 'token.nocapture'
132
+            '2':
133
+                'name': 'punctuation'
134
+            '3':
135
+                'name': 'constant.name'
136
+            '4':
137
+                'name': 'punctuation'
138
+        'match': '((::)([^\\s:]+)(::))'
139
+
140
+    'rule_call':
141
+        'captures':
142
+            '1':
143
+                'name': 'rule.call'
144
+            '2':
145
+                'name': 'variable.name'
146
+        'match': '(([^\\s]+)\\(\\))'
147
+
148
+    'node_call':
149
+        'captures':
150
+            '1':
151
+                'name': 'node.call'
152
+            '2':
153
+                'name': 'variable.name'
154
+            '3':
155
+                'name': 'punctuation'
156
+        'match': '(((#)\\w+))'

+ 16
- 0
package.json View File

@@ -0,0 +1,16 @@
1
+{
2
+  "name": "hoa-compiler-plugin",
3
+  "version": "0.0.0",
4
+  "description": "Atom tools tools for the PP grammar description language from the PHP Hoa\\Compiler library",
5
+  "keywords": ["php", "hoa", "compiler", "pp", "grammar", "language"],
6
+  "activationCommands": {
7
+    "atom-workspace": "atom-compiler-plugin:toggle"
8
+  },
9
+  "repository": "https://github.com/hoaproject/Contributions-Atom-Pp.git",
10
+  "license": "BSD-3-Clause",
11
+  "engines": {
12
+    "atom": "*"
13
+  },
14
+  "dependencies": {
15
+  }
16
+}

+ 6
- 0
settings/hoa-compiler-plugin.cson View File

@@ -0,0 +1,6 @@
1
+'.source.hoa.compiler.pp':
2
+    'editor':
3
+        'autoIndentOnPaste': true
4
+        'commentStart': '//'
5
+        'foldEndPattern': '^$'
6
+        'increaseIndentPattern': '^#?[^\\s]+:$'

+ 33
- 0
styles/hoa-compiler-plugin.less View File

@@ -0,0 +1,33 @@
1
+/**
2
+ * Hoa
3
+ *
4
+ *
5
+ * New BSD License
6
+ *
7
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
8
+ *
9
+ * Redistribution and use in source and binary forms, with or without
10
+ * modification, are permitted provided that the following conditions are met:
11
+ *     * Redistributions of source code must retain the above copyright
12
+ *       notice, this list of conditions and the following disclaimer.
13
+ *     * Redistributions in binary form must reproduce the above copyright
14
+ *       notice, this list of conditions and the following disclaimer in the
15
+ *       documentation and/or other materials provided with the distribution.
16
+ *     * Neither the name of the Hoa nor the names of its contributors may be
17
+ *       used to endorse or promote products derived from this software without
18
+ *       specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
24
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+ * POSSIBILITY OF SUCH DAMAGE.
31
+ */
32
+
33
+@import "ui-variables";

+ 96
- 0
test.pp View File

@@ -0,0 +1,96 @@
1
+//
2
+// Hoa
3
+//
4
+//
5
+// @license
6
+//
7
+// New BSD License
8
+//
9
+// Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
10
+//
11
+// Redistribution and use in source and binary forms, with or without
12
+// modification, are permitted provided that the following conditions are met:
13
+//     * Redistributions of source code must retain the above copyright
14
+//       notice, this list of conditions and the following disclaimer.
15
+//     * Redistributions in binary form must reproduce the above copyright
16
+//       notice, this list of conditions and the following disclaimer in the
17
+//       documentation and/or other materials provided with the distribution.
18
+//     * Neither the name of the Hoa nor the names of its contributors may be
19
+//       used to endorse or promote products derived from this software without
20
+//       specific prior written permission.
21
+//
22
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
26
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+// POSSIBILITY OF SUCH DAMAGE.
33
+//
34
+// Grammar \Hoa\Compiler\Llk.
35
+//
36
+// Provide grammar for the LL(k) parser.
37
+//
38
+// @author     Ivan Enderlin <ivan.enderlin@hoa-project.net>
39
+// @copyright  Copyright © 2007-2015 Ivan Enderlin.
40
+// @license    New BSD License
41
+//
42
+
43
+
44
+%skip   space          \s
45
+
46
+%token  or             \|
47
+%token  zero_or_one    \?
48
+%token  one_or_more    \+
49
+%token  zero_or_more   \*
50
+%token  n_to_m         \{[0-9]+,[0-9]+\}
51
+%token  zero_to_m      \{,[0-9]+\}
52
+%token  n_or_more      \{[0-9]+,\}
53
+%token  exactly_n      \{[0-9]+\}
54
+
55
+%token  token          [a-zA-Z_][a-zA-Z0-9_]*
56
+
57
+%token  skipped        ::
58
+%token  kept_          <
59
+%token _kept           >
60
+%token  named          \(\)
61
+%token  node           #[a-zA-Z][a-zA-Z0-9]+
62
+
63
+%token  capturing_     \(
64
+%token _capturing      \)
65
+%token  unification_   \[
66
+%token  unification    [0-9]+
67
+%token _unification    \]
68
+
69
+#rule:
70
+    choice()
71
+
72
+choice:
73
+    concatenation() ( ::or:: concatenation() #choice )*
74
+
75
+concatenation:
76
+    repetition() ( repetition() #concatenation )*
77
+
78
+repetition:
79
+    simple() ( quantifier() #repetition )? <node>?
80
+
81
+simple:
82
+    ::capturing_:: choice() ::_capturing::
83
+  | ::skipped:: <token> ( ::unification_:: <unification> ::_unification:: )?
84
+    ::skipped:: #skipped
85
+  | ::kept_:: <token> ( ::unification_:: <unification> ::_unification:: )?
86
+    ::_kept:: #kept
87
+  | <token> ::named::
88
+    ( ::unification_:: <unification> ::_unification:: )? #named
89
+
90
+quantifier:
91
+    <zero_or_one>
92
+  | <one_or_more>
93
+  | <zero_or_more>
94
+  | <n_to_m>
95
+  | <n_or_more>
96
+  | <exactly_n>

Loading…
Cancel
Save