Skip to content

Commit

Permalink
Added support for PC-Axis file format (#1940)
Browse files Browse the repository at this point in the history
This adds a new language for the PC-Axis file format.
  • Loading branch information
RunDevelopment authored Jul 3, 2019
1 parent de10bd1 commit 473f7fb
Show file tree
Hide file tree
Showing 14 changed files with 291 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,11 @@
},
"owner": "Golmote"
},
"pcaxis": {
"title": "PC-Axis",
"alias": "px",
"owner": "RunDevelopment"
},
"perl": {
"title": "Perl",
"owner": "Golmote"
Expand Down
53 changes: 53 additions & 0 deletions components/prism-pcaxis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Prism.languages.pcaxis = {
'string': /"[^"]*"/,
'keyword': {
pattern: /((?:^|;)\s*)[-A-Z\d]+(?:\s*\[[-\w]+\])?(?:\s*\("[^"]*"(?:,\s*"[^"]*")*\))?(?=\s*=)/,
lookbehind: true,
greedy: true,
inside: {
'keyword': /^[-A-Z\d]+/,
'language': {
pattern: /^(\s*)\[[-\w]+\]/,
lookbehind: true,
inside: {
'punctuation': /^\[|\]$/,
'property': /[-\w]+/
}
},
'sub-key': {
pattern: /^(\s*)[\s\S]+/,
lookbehind: true,
inside: {
'parameter': {
pattern: /"[^"]*"/,
alias: 'property'
},
'punctuation': /^\(|\)$|,/
}
}
}
},
'operator': /=/,
'tlist': {
pattern: /TLIST\s*\(\s*\w+(?:(?:\s*,\s*"[^"]*")+|\s*,\s*"[^"]*"-"[^"]*")?\s*\)/,
greedy: true,
inside: {
'function': /^TLIST/,
'property': {
pattern: /^(\s*\(\s*)\w+/,
lookbehind: true
},
'string': /"[^"]*"/,
'punctuation': /[(),]/,
'operator': /-/
}
},
'punctuation': /[;,]/,
'number': {
pattern: /(^|\s)\d+(?:\.\d+)?(?!\S)/,
lookbehind: true
},
'boolean': /YES|NO/,
};

Prism.languages.px = Prism.languages.pcaxis;
1 change: 1 addition & 0 deletions components/prism-pcaxis.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions examples/prism-pcaxis.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<h2>Full example</h2>
<pre><code>CHARSET="ANSI";
AXIS-VERSION="2000";
LANGUAGE="en";
CREATION-DATE="20170406 11:08";
TIMEVAL("time")=TLIST(A1, "1994"-"1996");
SUBJECT-AREA="";
UNITS="Number";

STUB="County","Sex";
VALUES("County")="State","Carlow","Dublin","Kildare","Kilkenny","Laois","Longford","Louth","Meath","Offaly","Westmeath","Wexford",
"Wicklow","Clare","Cork","Kerry","Limerick","Tipperary","Waterford","Galway","Leitrim","Mayo","Roscommon","Sligo","Cavan",
"Donegal","Monaghan";
VALUES("Sex")="Both sexes","Male","Female";
VALUES[de]("Sex")="Beide Geschlechter","Mann","Frau";
CODES("County")="-","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26";
CODES("Sex")="-","1","2";

DATA=
47163 87913 70192 84531 93120 343 5911 47038 51126 47870 95976 5643 66043 38987 63125 46882
57422 89992 11661 35817 92686 21781 37230 80669 14129 56688 81300 20184 88680 52135 17148 28192
92218 99175 76054 79907 90207 50547 31522 4244 91079 58776 83402 54109 21254 42946 83519 31242
10925 37377 45279 19704 96633 51732 34458 9746 91761 42687 51681 54409 61058 74227 70802 34546
64862 12022 29896 23616 50371 89808 57186 63895 94767 76388 66475 56716 50133 6604 52853 40763
70558 74672 58190 40909 6869 49937 9271 28067 99656 25674 69442 20608 28046 73287 60416 77515
51639 15516 40968 95524 6694 12956 83150 77099 45687 27241 6492 94966 36856 60693 720 74671
17309 4831 69376 67757 67499 69029 5209 50738 86947 77747 10996 9167 69176 98856 29531 5865
27654 52277 62293 30179 85049 76961 92772 65142 16252 6768 55784 20556 26088 97219 97245 44060
64577 91018 75157 42780 96186 62948 73288 74597 2145 16047 1671 2690 2275 45398 71478 53720
94832 91800 10398 84830 6009 9024 53132 97850 63832 13269 45376 38564 60343 85293 9330 16810
24898 76675 32778 26905 40945 37569 43532 38650 38316 75398 60829 91004 97946 49080 93534 78275
20002 87183 80802 56487 12666 18416 91632 74573 70729 97984 48479 93014 10281 90382 28497 15366
29720 25646 98513 47065 37662 94058 17383 47234 87293 37849 32087 98641 62012 12584 35492 87090
85157 90539 31005 67590 13627 44803 46789 8026 86877 18429 8935 78118 41728 67025 69312 52172
49224 68064 93025 1195 64873 684 90039 86065 67324 66534 1110 22354 36867 27479 76286 8539</code></pre>
1 change: 1 addition & 0 deletions plugins/autoloader/prism-autoloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
"md": "markdown",
"n4jsd": "n4js",
"objectpascal": "pascal",
"px": "pcaxis",
"py": "python",
"rb": "ruby",
"ts": "typescript",
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
"opencl": "OpenCL",
"parigp": "PARI/GP",
"objectpascal": "Object Pascal",
"pcaxis": "PC-Axis",
"px": "PC-Axis",
"php": "PHP",
"phpdoc": "PHPDoc",
"php-extras": "PHP Extras",
Expand Down
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions tests/languages/pcaxis/boolean_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
YES
NO

----------------------------------------------------

[
["boolean", "YES"],
["boolean", "NO"]
]

----------------------------------------------------

Checks for booleans.
76 changes: 76 additions & 0 deletions tests/languages/pcaxis/keyword_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
FOO=0;
FOO[en]=1;
FOO("param")=0;
FOO("param1","param2")=0;
FOO-BAR[en]("param1","param2")=1;

----------------------------------------------------

[
["keyword", [
["keyword", "FOO"]
]],
["operator", "="],
["number", "0"],
["punctuation", ";"],
["keyword", [
["keyword", "FOO"],
["language", [
["punctuation", "["],
["property", "en"],
["punctuation", "]"]
]]
]],
["operator", "="],
["number", "1"],
["punctuation", ";"],

["keyword", [
["keyword", "FOO"],
["sub-key", [
["punctuation", "("],
["parameter", "\"param\""],
["punctuation", ")"]
]]
]],
["operator", "="],
["number", "0"],
["punctuation", ";"],

["keyword", [
["keyword", "FOO"],
["sub-key", [
["punctuation", "("],
["parameter", "\"param1\""],
["punctuation", ","],
["parameter", "\"param2\""],
["punctuation", ")"]
]]
]],
["operator", "="],
["number", "0"],
["punctuation", ";"],

["keyword", [
["keyword", "FOO-BAR"],
["language", [
["punctuation", "["],
["property", "en"],
["punctuation", "]"]
]],
["sub-key", [
["punctuation", "("],
["parameter", "\"param1\""],
["punctuation", ","],
["parameter", "\"param2\""],
["punctuation", ")"]
]]
]],
["operator", "="],
["number", "1"],
["punctuation", ";"]
]

----------------------------------------------------

Checks for keywords.
17 changes: 17 additions & 0 deletions tests/languages/pcaxis/number_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
0
123456789
123.456
0.123

----------------------------------------------------

[
["number", "0"],
["number", "123456789"],
["number", "123.456"],
["number", "0.123"]
]

----------------------------------------------------

Checks for numbers.
13 changes: 13 additions & 0 deletions tests/languages/pcaxis/string_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"foo ,; ()[] bar"
""

----------------------------------------------------

[
["string", "\"foo ,; ()[] bar\""],
["string", "\"\""]
]

----------------------------------------------------

Checks for strings.
Loading

0 comments on commit 473f7fb

Please sign in to comment.