Skip to content

Commit b87260e

Browse files
committed
add file names to import output
1 parent b0c7d86 commit b87260e

File tree

6 files changed

+21
-11
lines changed

6 files changed

+21
-11
lines changed

‎parser/compile/loadImports.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ function loadImports(str) {
1515
const fileName = i.slice(9, -2);
1616

1717
// load import
18-
let file = readFileSync(join(__dirname, '../pegjs/', fileName), 'utf8');
19-
18+
let file = `/*** "${join('pegjs', fileName)}" ***/\n\n`;
19+
file += readFileSync(join(__dirname, '../pegjs/', fileName), 'utf8');
2020

2121
// indent js files
2222
if (!fileName.match(pegjs)) {

‎parser/index.pegjs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
// Initial Data
2+
/*** "pegjs/_data.js" ***/
33

44
var output = {
55
info: {
@@ -9,12 +9,12 @@
99
pages: []
1010
};
1111

12-
// Types
12+
/*** "pegjs/_types.js" ***/
1313

1414
const pageTypes = ['onPageComplete'];
1515
const taskTypes = ['tests', 'actions', 'hints']
1616

17-
// Helper Functions
17+
/*** "pegjs/_functions.js" ***/
1818

1919
function adjust(item) {
2020
return item[0].concat(item[1].join(''));
@@ -59,6 +59,8 @@ doc
5959
break?
6060
page*
6161

62+
/*** "pegjs/info.pegjs" ***/
63+
6264
info
6365
= title: info_title
6466
description: description*
@@ -73,6 +75,8 @@ info_title
7375
title: content
7476
{ return adjust(title); }
7577

78+
/*** "pegjs/page.pegjs" ***/
79+
7680
page
7781
= title: page_title
7882
description: description*
@@ -85,6 +89,7 @@ page
8589
description: description.join('\n'),
8690
tasks
8791
}
92+
8893
// map over any actions and add them
8994
actions.forEach(({type, value}) => {
9095
if (page.hasOwnProperty(type)) {
@@ -102,6 +107,8 @@ page_title
102107
break
103108
{ return adjust(title); }
104109

110+
/*** "pegjs/task.pegjs" ***/
111+
105112
page_task
106113
= '+'
107114
space?
@@ -144,6 +151,8 @@ task_hint
144151
return { type: 'hints', value: h };
145152
}
146153

154+
/*** "pegjs/page-actions.pegjs" ***/
155+
147156
page_actions
148157
= on_page_complete
149158

@@ -157,6 +166,8 @@ on_page_complete
157166
break
158167
{ return { type: 'onPageComplete', value: content.join('') }; }
159168

169+
/*** "pegjs/task-actions.pegjs" ***/
170+
160171
task_action
161172
= '@action'
162173
'('
@@ -215,11 +226,15 @@ action_write_from_file
215226
quote
216227
')'
217228

229+
/*** "pegjs/shared.pegjs" ***/
230+
218231
description
219232
= description: content
220233
break
221234
{ return adjust(description); }
222235

236+
/*** "pegjs/characters.pegjs" ***/
237+
223238
content = [^#^@^+] [^\n^\r]+ [\n\r]
224239
space = [ \s]
225240
break = [\n\r]?

‎parser/pegjs/_data.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Initial Data
2-
31
var output = {
42
info: {
53
title: 'Tutorial Title',

‎parser/pegjs/_functions.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Helper Functions
2-
31
function adjust(item) {
42
return item[0].concat(item[1].join(''));
53
}

‎parser/pegjs/_types.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
// Types
2-
31
const pageTypes = ['onPageComplete'];
42
const taskTypes = ['tests', 'actions', 'hints']

‎parser/pegjs/page.pegjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ page
1010
description: description.join('\n'),
1111
tasks
1212
}
13+
1314
// map over any actions and add them
1415
actions.forEach(({type, value}) => {
1516
if (page.hasOwnProperty(type)) {

0 commit comments

Comments
 (0)