Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit ed789e7

Browse files
authored
bf-lu: support new link reference format (#961)
* add reference support * optimize and add tests * add test case to verify reference can be a URL * add negative tests
1 parent d7b6149 commit ed789e7

27 files changed

+1902
-1357
lines changed

packages/lu/src/parser/lu/luMerger.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,7 @@ const resolveLuUriContent = async function(srcId, toResolve, luObjects) {
463463
// throw, invalid URI
464464
let errorMsg = `URI: "${uri}" appears to be invalid. Please double check the URI or re-try this parse when you are connected to the internet.`;
465465
let error = BuildDiagnostic({
466-
message: errorMsg,
467-
range: luImport.Range
466+
message: errorMsg
468467
})
469468

470469
throw (new exception(retCode.errorCode.INVALID_URI, error.toString(), [error]));

packages/lu/src/parser/lufile/LUFileLexer.g4

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ AT
7878
;
7979

8080
IMPORT
81-
: '[' ~[\r\n[\]]*? ']' '(' ~[\r\n()]*? ')'
81+
: '[' ~[\r\n[\]]*? ']' ('(' ~[\r\n()]*? ')' | '[' ~[\r\n[\]]*? ']')
82+
;
83+
84+
REFERENCE
85+
: '[' ~[\r\n[\]]*? ']' WS* ':' WS* ~[\r\n]*
8286
;
8387

8488
FILTER_MARK

packages/lu/src/parser/lufile/LUFileParser.g4

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ paragraph
1313
| entitySection
1414
| newEntitySection
1515
| importSection
16+
| referenceSection
1617
| qnaSection
1718
| modelInfoSection
1819
;
@@ -172,6 +173,14 @@ importDefinition
172173
: WS* IMPORT WS*
173174
;
174175

176+
referenceSection
177+
: referenceDefinition
178+
;
179+
180+
referenceDefinition
181+
: WS* REFERENCE WS*
182+
;
183+
175184
qnaSection
176185
: qnaDefinition
177186
;

packages/lu/src/parser/lufile/generated/LUFileLexer.interp

Lines changed: 4 additions & 1 deletion
Large diffs are not rendered by default.

packages/lu/src/parser/lufile/generated/LUFileLexer.js

Lines changed: 487 additions & 458 deletions
Large diffs are not rendered by default.

packages/lu/src/parser/lufile/generated/LUFileLexer.tokens

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,38 @@ DASH=8
99
DOLLAR=9
1010
AT=10
1111
IMPORT=11
12-
FILTER_MARK=12
13-
QNA_ID_MARK=13
14-
MULTI_LINE_TEXT=14
15-
PROMPT_MARK=15
16-
INVALID_TOKEN_DEFAULT_MODE=16
17-
EQUAL=17
18-
COMMA=18
19-
HAS_ROLES_LABEL=19
20-
HAS_FEATURES_LABEL=20
21-
NEW_ENTITY_TYPE_IDENTIFIER=21
22-
PHRASE_LIST_LABEL=22
23-
NEW_COMPOSITE_ENTITY=23
24-
NEW_REGEX_ENTITY=24
25-
NEW_ENTITY_IDENTIFIER=25
26-
NEW_ENTITY_IDENTIFIER_WITH_WS=26
27-
NEWLINE_IN_NAME=27
28-
IDENTIFIER=28
29-
DOT=29
30-
ESCAPE_CHARACTER=30
31-
EXPRESSION=31
32-
TEXT=32
33-
NEWLINE_IN_ENTITY=33
34-
COMPOSITE_ENTITY=34
35-
REGEX_ENTITY=35
36-
ENTITY_TEXT=36
37-
COLON_MARK=37
38-
NEWLINE_IN_QNA=38
39-
QNA_TEXT=39
12+
REFERENCE=12
13+
FILTER_MARK=13
14+
QNA_ID_MARK=14
15+
MULTI_LINE_TEXT=15
16+
PROMPT_MARK=16
17+
INVALID_TOKEN_DEFAULT_MODE=17
18+
EQUAL=18
19+
COMMA=19
20+
HAS_ROLES_LABEL=20
21+
HAS_FEATURES_LABEL=21
22+
NEW_ENTITY_TYPE_IDENTIFIER=22
23+
PHRASE_LIST_LABEL=23
24+
NEW_COMPOSITE_ENTITY=24
25+
NEW_REGEX_ENTITY=25
26+
NEW_ENTITY_IDENTIFIER=26
27+
NEW_ENTITY_IDENTIFIER_WITH_WS=27
28+
NEWLINE_IN_NAME=28
29+
IDENTIFIER=29
30+
DOT=30
31+
ESCAPE_CHARACTER=31
32+
EXPRESSION=32
33+
TEXT=33
34+
NEWLINE_IN_ENTITY=34
35+
COMPOSITE_ENTITY=35
36+
REGEX_ENTITY=36
37+
ENTITY_TEXT=37
38+
COLON_MARK=38
39+
NEWLINE_IN_QNA=39
40+
QNA_TEXT=40
4041
'$'=9
4142
'@'=10
42-
'='=17
43-
','=18
44-
'.'=29
45-
':'=37
43+
'='=18
44+
','=19
45+
'.'=30
46+
':'=38

packages/lu/src/parser/lufile/generated/LUFileParser.interp

Lines changed: 5 additions & 1 deletion
Large diffs are not rendered by default.

packages/lu/src/parser/lufile/generated/LUFileParser.js

Lines changed: 1019 additions & 820 deletions
Large diffs are not rendered by default.

packages/lu/src/parser/lufile/generated/LUFileParser.tokens

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,38 @@ DASH=8
99
DOLLAR=9
1010
AT=10
1111
IMPORT=11
12-
FILTER_MARK=12
13-
QNA_ID_MARK=13
14-
MULTI_LINE_TEXT=14
15-
PROMPT_MARK=15
16-
INVALID_TOKEN_DEFAULT_MODE=16
17-
EQUAL=17
18-
COMMA=18
19-
HAS_ROLES_LABEL=19
20-
HAS_FEATURES_LABEL=20
21-
NEW_ENTITY_TYPE_IDENTIFIER=21
22-
PHRASE_LIST_LABEL=22
23-
NEW_COMPOSITE_ENTITY=23
24-
NEW_REGEX_ENTITY=24
25-
NEW_ENTITY_IDENTIFIER=25
26-
NEW_ENTITY_IDENTIFIER_WITH_WS=26
27-
NEWLINE_IN_NAME=27
28-
IDENTIFIER=28
29-
DOT=29
30-
ESCAPE_CHARACTER=30
31-
EXPRESSION=31
32-
TEXT=32
33-
NEWLINE_IN_ENTITY=33
34-
COMPOSITE_ENTITY=34
35-
REGEX_ENTITY=35
36-
ENTITY_TEXT=36
37-
COLON_MARK=37
38-
NEWLINE_IN_QNA=38
39-
QNA_TEXT=39
12+
REFERENCE=12
13+
FILTER_MARK=13
14+
QNA_ID_MARK=14
15+
MULTI_LINE_TEXT=15
16+
PROMPT_MARK=16
17+
INVALID_TOKEN_DEFAULT_MODE=17
18+
EQUAL=18
19+
COMMA=19
20+
HAS_ROLES_LABEL=20
21+
HAS_FEATURES_LABEL=21
22+
NEW_ENTITY_TYPE_IDENTIFIER=22
23+
PHRASE_LIST_LABEL=23
24+
NEW_COMPOSITE_ENTITY=24
25+
NEW_REGEX_ENTITY=25
26+
NEW_ENTITY_IDENTIFIER=26
27+
NEW_ENTITY_IDENTIFIER_WITH_WS=27
28+
NEWLINE_IN_NAME=28
29+
IDENTIFIER=29
30+
DOT=30
31+
ESCAPE_CHARACTER=31
32+
EXPRESSION=32
33+
TEXT=33
34+
NEWLINE_IN_ENTITY=34
35+
COMPOSITE_ENTITY=35
36+
REGEX_ENTITY=36
37+
ENTITY_TEXT=37
38+
COLON_MARK=38
39+
NEWLINE_IN_QNA=39
40+
QNA_TEXT=40
4041
'$'=9
4142
'@'=10
42-
'='=17
43-
','=18
44-
'.'=29
45-
':'=37
43+
'='=18
44+
','=19
45+
'.'=30
46+
':'=38

packages/lu/src/parser/lufile/generated/LUFileParserListener.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,24 @@ LUFileParserListener.prototype.exitImportDefinition = function(ctx) {
371371
};
372372

373373

374+
// Enter a parse tree produced by LUFileParser#referenceSection.
375+
LUFileParserListener.prototype.enterReferenceSection = function(ctx) {
376+
};
377+
378+
// Exit a parse tree produced by LUFileParser#referenceSection.
379+
LUFileParserListener.prototype.exitReferenceSection = function(ctx) {
380+
};
381+
382+
383+
// Enter a parse tree produced by LUFileParser#referenceDefinition.
384+
LUFileParserListener.prototype.enterReferenceDefinition = function(ctx) {
385+
};
386+
387+
// Exit a parse tree produced by LUFileParser#referenceDefinition.
388+
LUFileParserListener.prototype.exitReferenceDefinition = function(ctx) {
389+
};
390+
391+
374392
// Enter a parse tree produced by LUFileParser#qnaSection.
375393
LUFileParserListener.prototype.enterQnaSection = function(ctx) {
376394
};

0 commit comments

Comments
 (0)