Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Port] Support create object with multi lines in LG #2756

Merged
merged 5 commits into from
Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const dataSource = [
['alist[0].Name', 'item1'],

// string interpolation test
["``", ''],
['``', ''],
['`hi`', 'hi'],
['`hi\\``', 'hi`'],
['`${world}`', 'world'],
Expand Down
2 changes: 1 addition & 1 deletion libraries/botbuilder-lg/src/LGTemplateLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fragment ESCAPE_CHARACTER_FRAGMENT : '\\' ~[\r\n]?;
fragment IDENTIFIER : (LETTER | NUMBER | '_') (LETTER | NUMBER | '_')*;

fragment OBJECT_DEFINITION
: '{' ((WHITESPACE) | ((IDENTIFIER | STRING_LITERAL) ':' ( STRING_LITERAL | ~[{}\r\n'"`] | OBJECT_DEFINITION)+))* '}'
: '{' ((WHITESPACE) | ((IDENTIFIER | STRING_LITERAL) ':' ( STRING_LITERAL | ~[{}'"`] | OBJECT_DEFINITION)+))* '}'
;

fragment EXPRESSION_FRAGMENT
Expand Down
130 changes: 65 additions & 65 deletions libraries/botbuilder-lg/src/generated/LGTemplateLexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,66 +613,66 @@ export class LGTemplateLexer extends Lexer {
"Hhh\x04\x02JJjj\x04\x02KKkk\x04\x02NNnn\x04\x02UUuu\x04\x02VVvv\x04\x02" +
"WWww\x04\x02YYyy\x04\x02C\\c|\x06\x02\v\v\"\"\xA2\xA2\uFF01\uFF01\x04" +
"\x02))^^\x03\x02))\x04\x02$$^^\x03\x02$$\x04\x02^^bb\x03\x02bb\x04\x02" +
"\f\f\x0F\x0F\t\x02\f\f\x0F\x0F$$))bb}}\x7F\x7F\x06\x02$$))bb\x7F\x7F\x04" +
"\x02/0aa\x02\u023D\x021\x03\x02\x02\x02\x023\x03\x02\x02\x02\x025\x03" +
"\x02\x02\x02\x027\x03\x02\x02\x02\x029\x03\x02\x02\x02\x02;\x03\x02\x02" +
"\x02\x03=\x03\x02\x02\x02\x03?\x03\x02\x02\x02\x03A\x03\x02\x02\x02\x03" +
"C\x03\x02\x02\x02\x03E\x03\x02\x02\x02\x03G\x03\x02\x02\x02\x03I\x03\x02" +
"\x02\x02\x03K\x03\x02\x02\x02\x03M\x03\x02\x02\x02\x03O\x03\x02\x02\x02" +
"\x03Q\x03\x02\x02\x02\x03S\x03\x02\x02\x02\x04U\x03\x02\x02\x02\x04W\x03" +
"\x02\x02\x02\x04Y\x03\x02\x02\x02\x04[\x03\x02\x02\x02\x05]\x03\x02\x02" +
"\x02\x05_\x03\x02\x02\x02\x05a\x03\x02\x02\x02\x05c\x03\x02\x02\x02\x06" +
"e\x03\x02\x02\x02\x06g\x03\x02\x02\x02\x06i\x03\x02\x02\x02\x06k\x03\x02" +
"\x02\x02\x06m\x03\x02\x02\x02\x06o\x03\x02\x02\x02\x06q\x03\x02\x02\x02" +
"\x06s\x03\x02\x02\x02\x06u\x03\x02\x02\x02\x06w\x03\x02\x02\x02\x07y\x03" +
"\x02\x02\x02\t{\x03\x02\x02\x02\v}\x03\x02\x02\x02\r\x7F\x03\x02\x02\x02" +
"\x0F\x81\x03\x02\x02\x02\x11\x83\x03\x02\x02\x02\x13\x85\x03\x02\x02\x02" +
"\x15\x87\x03\x02\x02\x02\x17\x89\x03\x02\x02\x02\x19\x8B\x03\x02\x02\x02" +
"\x1B\x8D\x03\x02\x02\x02\x1D\x8F\x03\x02\x02\x02\x1F\x91\x03\x02\x02\x02" +
"!\x93\x03\x02\x02\x02#\x95\x03\x02\x02\x02%\xAB\x03\x02\x02\x02\'\xAD" +
"\x03\x02\x02\x02)\xB8\x03\x02\x02\x02+\xBF\x03\x02\x02\x02-\xC9\x03\x02" +
"\x02\x02/\xDE\x03\x02\x02\x021\xEC\x03\x02\x02\x023\xF3\x03\x02\x02\x02" +
"5\xF9\x03\x02\x02\x027\u0102\x03\x02\x02\x029\u0107\x03\x02\x02\x02;\u010D" +
"\x03\x02\x02\x02=\u0111\x03\x02\x02\x02?\u0119\x03\x02\x02\x02A\u0123" +
"\x03\x02\x02\x02C\u012B\x03\x02\x02\x02E\u0137\x03\x02\x02\x02G\u014D" +
"\x03\x02\x02\x02I\u015B\x03\x02\x02\x02K\u016B\x03\x02\x02\x02M\u0179" +
"\x03\x02\x02\x02O\u018A\x03\x02\x02\x02Q\u018D\x03\x02\x02\x02S\u0191" +
"\x03\x02\x02\x02U\u0197\x03\x02\x02\x02W\u019F\x03\x02\x02\x02Y\u01A3" +
"\x03\x02\x02\x02[\u01AC\x03\x02\x02\x02]\u01B3\x03\x02\x02\x02_\u01BA" +
"\x03\x02\x02\x02a\u01C6\x03\x02\x02\x02c\u01D1\x03\x02\x02\x02e\u01D5" +
"\x03\x02\x02\x02g\u01E5\x03\x02\x02\x02i\u01EE\x03\x02\x02\x02k\u01F3" +
"\x03\x02\x02\x02m\u01FC\x03\x02\x02\x02o\u0209\x03\x02\x02\x02q\u020D" +
"\x03\x02\x02\x02s\u0210\x03\x02\x02\x02u\u0213\x03\x02\x02\x02w\u0217" +
"\x03\x02\x02\x02yz\t\x02\x02\x02z\b\x03\x02\x02\x02{|\t\x03\x02\x02|\n" +
"\x03\x02\x02\x02}~\t\x04\x02\x02~\f\x03\x02\x02\x02\x7F\x80\t\x05\x02" +
"\x02\x80\x0E\x03\x02\x02\x02\x81\x82\t\x06\x02\x02\x82\x10\x03\x02\x02" +
"\x02\x83\x84\t\x07\x02\x02\x84\x12\x03\x02\x02\x02\x85\x86\t\b\x02\x02" +
"\x86\x14\x03\x02\x02\x02\x87\x88\t\t\x02\x02\x88\x16\x03\x02\x02\x02\x89" +
"\x8A\t\n\x02\x02\x8A\x18\x03\x02\x02\x02\x8B\x8C\t\v\x02\x02\x8C\x1A\x03" +
"\x02\x02\x02\x8D\x8E\t\f\x02\x02\x8E\x1C\x03\x02\x02\x02\x8F\x90\t\r\x02" +
"\x02\x90\x1E\x03\x02\x02\x02\x91\x92\t\x0E\x02\x02\x92 \x03\x02\x02\x02" +
"\x93\x94\x042;\x02\x94\"\x03\x02\x02\x02\x95\x96\t\x0F\x02\x02\x96$\x03" +
"\x02\x02\x02\x97\x9D\x07)\x02\x02\x98\x99\x07^\x02\x02\x99\x9C\t\x10\x02" +
"\x02\x9A\x9C\n\x11\x02\x02\x9B\x98\x03\x02\x02\x02\x9B\x9A\x03\x02\x02" +
"\x02\x9C\x9F\x03\x02\x02\x02\x9D\x9E\x03\x02\x02\x02\x9D\x9B\x03\x02\x02" +
"\x02\x9E\xA0\x03\x02\x02\x02\x9F\x9D\x03\x02\x02\x02\xA0\xAC\x07)\x02" +
"\x02\xA1\xA7\x07$\x02\x02\xA2\xA3\x07^\x02\x02\xA3\xA6\t\x12\x02\x02\xA4" +
"\xA6\n\x13\x02\x02\xA5\xA2\x03\x02\x02\x02\xA5\xA4\x03\x02\x02\x02\xA6" +
"\xA9\x03\x02\x02\x02\xA7\xA8\x03\x02\x02\x02\xA7\xA5\x03\x02\x02\x02\xA8" +
"\xAA\x03\x02\x02\x02\xA9\xA7\x03\x02\x02\x02\xAA\xAC\x07$\x02\x02\xAB" +
"\x97\x03\x02\x02\x02\xAB\xA1\x03\x02\x02\x02\xAC&\x03\x02\x02\x02\xAD" +
"\xB3\x07b\x02\x02\xAE\xAF\x07^\x02\x02\xAF\xB2\t\x14\x02\x02\xB0\xB2\n" +
"\x15\x02\x02\xB1\xAE\x03\x02\x02\x02\xB1\xB0\x03\x02\x02\x02\xB2\xB5\x03" +
"\x02\x02\x02\xB3\xB4\x03\x02\x02\x02\xB3\xB1\x03\x02\x02\x02\xB4\xB6\x03" +
"\x02\x02\x02\xB5\xB3\x03\x02\x02\x02\xB6\xB7\x07b\x02\x02\xB7(\x03\x02" +
"\x02\x02\xB8\xBA\x07^\x02\x02\xB9\xBB\n\x16\x02\x02\xBA\xB9\x03\x02\x02" +
"\x02\xBA\xBB\x03\x02\x02\x02\xBB*\x03\x02\x02\x02\xBC\xC0\x05\x1F\x0E" +
"\x02\xBD\xC0\x05!\x0F\x02\xBE\xC0\x07a\x02\x02\xBF\xBC\x03\x02\x02\x02" +
"\xBF\xBD\x03\x02\x02\x02\xBF\xBE\x03\x02\x02\x02\xC0\xC6\x03\x02\x02\x02" +
"\xC1\xC5\x05\x1F\x0E\x02\xC2\xC5\x05!\x0F\x02\xC3\xC5\x07a\x02\x02\xC4" +
"\xC1\x03\x02\x02\x02\xC4\xC2\x03\x02\x02\x02\xC4\xC3\x03\x02\x02\x02\xC5" +
"\xC8\x03\x02\x02\x02\xC6\xC4\x03\x02\x02\x02\xC6\xC7\x03\x02\x02\x02\xC7" +
",\x03\x02\x02\x02\xC8\xC6\x03\x02\x02\x02\xC9\xD9\x07}\x02\x02\xCA\xD8" +
"\f\f\x0F\x0F\x07\x02$$))bb}}\x7F\x7F\x06\x02$$))bb\x7F\x7F\x04\x02/0a" +
"a\x02\u023D\x021\x03\x02\x02\x02\x023\x03\x02\x02\x02\x025\x03\x02\x02" +
"\x02\x027\x03\x02\x02\x02\x029\x03\x02\x02\x02\x02;\x03\x02\x02\x02\x03" +
"=\x03\x02\x02\x02\x03?\x03\x02\x02\x02\x03A\x03\x02\x02\x02\x03C\x03\x02" +
"\x02\x02\x03E\x03\x02\x02\x02\x03G\x03\x02\x02\x02\x03I\x03\x02\x02\x02" +
"\x03K\x03\x02\x02\x02\x03M\x03\x02\x02\x02\x03O\x03\x02\x02\x02\x03Q\x03" +
"\x02\x02\x02\x03S\x03\x02\x02\x02\x04U\x03\x02\x02\x02\x04W\x03\x02\x02" +
"\x02\x04Y\x03\x02\x02\x02\x04[\x03\x02\x02\x02\x05]\x03\x02\x02\x02\x05" +
"_\x03\x02\x02\x02\x05a\x03\x02\x02\x02\x05c\x03\x02\x02\x02\x06e\x03\x02" +
"\x02\x02\x06g\x03\x02\x02\x02\x06i\x03\x02\x02\x02\x06k\x03\x02\x02\x02" +
"\x06m\x03\x02\x02\x02\x06o\x03\x02\x02\x02\x06q\x03\x02\x02\x02\x06s\x03" +
"\x02\x02\x02\x06u\x03\x02\x02\x02\x06w\x03\x02\x02\x02\x07y\x03\x02\x02" +
"\x02\t{\x03\x02\x02\x02\v}\x03\x02\x02\x02\r\x7F\x03\x02\x02\x02\x0F\x81" +
"\x03\x02\x02\x02\x11\x83\x03\x02\x02\x02\x13\x85\x03\x02\x02\x02\x15\x87" +
"\x03\x02\x02\x02\x17\x89\x03\x02\x02\x02\x19\x8B\x03\x02\x02\x02\x1B\x8D" +
"\x03\x02\x02\x02\x1D\x8F\x03\x02\x02\x02\x1F\x91\x03\x02\x02\x02!\x93" +
"\x03\x02\x02\x02#\x95\x03\x02\x02\x02%\xAB\x03\x02\x02\x02\'\xAD\x03\x02" +
"\x02\x02)\xB8\x03\x02\x02\x02+\xBF\x03\x02\x02\x02-\xC9\x03\x02\x02\x02" +
"/\xDE\x03\x02\x02\x021\xEC\x03\x02\x02\x023\xF3\x03\x02\x02\x025\xF9\x03" +
"\x02\x02\x027\u0102\x03\x02\x02\x029\u0107\x03\x02\x02\x02;\u010D\x03" +
"\x02\x02\x02=\u0111\x03\x02\x02\x02?\u0119\x03\x02\x02\x02A\u0123\x03" +
"\x02\x02\x02C\u012B\x03\x02\x02\x02E\u0137\x03\x02\x02\x02G\u014D\x03" +
"\x02\x02\x02I\u015B\x03\x02\x02\x02K\u016B\x03\x02\x02\x02M\u0179\x03" +
"\x02\x02\x02O\u018A\x03\x02\x02\x02Q\u018D\x03\x02\x02\x02S\u0191\x03" +
"\x02\x02\x02U\u0197\x03\x02\x02\x02W\u019F\x03\x02\x02\x02Y\u01A3\x03" +
"\x02\x02\x02[\u01AC\x03\x02\x02\x02]\u01B3\x03\x02\x02\x02_\u01BA\x03" +
"\x02\x02\x02a\u01C6\x03\x02\x02\x02c\u01D1\x03\x02\x02\x02e\u01D5\x03" +
"\x02\x02\x02g\u01E5\x03\x02\x02\x02i\u01EE\x03\x02\x02\x02k\u01F3\x03" +
"\x02\x02\x02m\u01FC\x03\x02\x02\x02o\u0209\x03\x02\x02\x02q\u020D\x03" +
"\x02\x02\x02s\u0210\x03\x02\x02\x02u\u0213\x03\x02\x02\x02w\u0217\x03" +
"\x02\x02\x02yz\t\x02\x02\x02z\b\x03\x02\x02\x02{|\t\x03\x02\x02|\n\x03" +
"\x02\x02\x02}~\t\x04\x02\x02~\f\x03\x02\x02\x02\x7F\x80\t\x05\x02\x02" +
"\x80\x0E\x03\x02\x02\x02\x81\x82\t\x06\x02\x02\x82\x10\x03\x02\x02\x02" +
"\x83\x84\t\x07\x02\x02\x84\x12\x03\x02\x02\x02\x85\x86\t\b\x02\x02\x86" +
"\x14\x03\x02\x02\x02\x87\x88\t\t\x02\x02\x88\x16\x03\x02\x02\x02\x89\x8A" +
"\t\n\x02\x02\x8A\x18\x03\x02\x02\x02\x8B\x8C\t\v\x02\x02\x8C\x1A\x03\x02" +
"\x02\x02\x8D\x8E\t\f\x02\x02\x8E\x1C\x03\x02\x02\x02\x8F\x90\t\r\x02\x02" +
"\x90\x1E\x03\x02\x02\x02\x91\x92\t\x0E\x02\x02\x92 \x03\x02\x02\x02\x93" +
"\x94\x042;\x02\x94\"\x03\x02\x02\x02\x95\x96\t\x0F\x02\x02\x96$\x03\x02" +
"\x02\x02\x97\x9D\x07)\x02\x02\x98\x99\x07^\x02\x02\x99\x9C\t\x10\x02\x02" +
"\x9A\x9C\n\x11\x02\x02\x9B\x98\x03\x02\x02\x02\x9B\x9A\x03\x02\x02\x02" +
"\x9C\x9F\x03\x02\x02\x02\x9D\x9E\x03\x02\x02\x02\x9D\x9B\x03\x02\x02\x02" +
"\x9E\xA0\x03\x02\x02\x02\x9F\x9D\x03\x02\x02\x02\xA0\xAC\x07)\x02\x02" +
"\xA1\xA7\x07$\x02\x02\xA2\xA3\x07^\x02\x02\xA3\xA6\t\x12\x02\x02\xA4\xA6" +
"\n\x13\x02\x02\xA5\xA2\x03\x02\x02\x02\xA5\xA4\x03\x02\x02\x02\xA6\xA9" +
"\x03\x02\x02\x02\xA7\xA8\x03\x02\x02\x02\xA7\xA5\x03\x02\x02\x02\xA8\xAA" +
"\x03\x02\x02\x02\xA9\xA7\x03\x02\x02\x02\xAA\xAC\x07$\x02\x02\xAB\x97" +
"\x03\x02\x02\x02\xAB\xA1\x03\x02\x02\x02\xAC&\x03\x02\x02\x02\xAD\xB3" +
"\x07b\x02\x02\xAE\xAF\x07^\x02\x02\xAF\xB2\t\x14\x02\x02\xB0\xB2\n\x15" +
"\x02\x02\xB1\xAE\x03\x02\x02\x02\xB1\xB0\x03\x02\x02\x02\xB2\xB5\x03\x02" +
"\x02\x02\xB3\xB4\x03\x02\x02\x02\xB3\xB1\x03\x02\x02\x02\xB4\xB6\x03\x02" +
"\x02\x02\xB5\xB3\x03\x02\x02\x02\xB6\xB7\x07b\x02\x02\xB7(\x03\x02\x02" +
"\x02\xB8\xBA\x07^\x02\x02\xB9\xBB\n\x16\x02\x02\xBA\xB9\x03\x02\x02\x02" +
"\xBA\xBB\x03\x02\x02\x02\xBB*\x03\x02\x02\x02\xBC\xC0\x05\x1F\x0E\x02" +
"\xBD\xC0\x05!\x0F\x02\xBE\xC0\x07a\x02\x02\xBF\xBC\x03\x02\x02\x02\xBF" +
"\xBD\x03\x02\x02\x02\xBF\xBE\x03\x02\x02\x02\xC0\xC6\x03\x02\x02\x02\xC1" +
"\xC5\x05\x1F\x0E\x02\xC2\xC5\x05!\x0F\x02\xC3\xC5\x07a\x02\x02\xC4\xC1" +
"\x03\x02\x02\x02\xC4\xC2\x03\x02\x02\x02\xC4\xC3\x03\x02\x02\x02\xC5\xC8" +
"\x03\x02\x02\x02\xC6\xC4\x03\x02\x02\x02\xC6\xC7\x03\x02\x02\x02\xC7," +
"\x03\x02\x02\x02\xC8\xC6\x03\x02\x02\x02\xC9\xD9\x07}\x02\x02\xCA\xD8" +
"\x05#\x10\x02\xCB\xCE\x05+\x14\x02\xCC\xCE\x05%\x11\x02\xCD\xCB\x03\x02" +
"\x02\x02\xCD\xCC\x03\x02\x02\x02\xCE\xCF\x03\x02\x02\x02\xCF\xD3\x07<" +
"\x02\x02\xD0\xD4\x05%\x11\x02\xD1\xD4\n\x17\x02\x02\xD2\xD4\x05-\x15\x02" +
Expand Down Expand Up @@ -815,12 +815,12 @@ export class LGTemplateLexer extends Lexer {
"\xD9\xE4\xE6\xE9\xEE\xF3\xFD\u0113\u0123\u0130\u013E\u0146\u0154\u0164" +
"\u0172\u0183\u0193\u01A8\u01AC\u01AE\u01B5\u01BA\u01C6\u01CB\u01CD\u01D3" +
"\u01D9\u01DD\u01E7\u01EE\u01FC\u0201\u0203\u0219#\b\x02\x02\x03\x1A\x02" +
"\x07\x03\x02\x03\x1B\x03\x07\x05\x02\x03";
"\x07\x03\x02\x03\x1B\x03\x07\x05\x02\x03\x1C\x04\x03\x1E";
private static readonly _serializedATNSegment1: string =
"\x1C\x04\x03\x1E\x05\x07\x04\x02\x03\x1F\x06\x06\x02\x02\x03 \x07\x03" +
"!\b\x03\"\t\x03#\n\x03$\v\x03%\f\x03&\r\x03\'\x0E\x03(\x0F\x03)\x10\t" +
"\x12\x02\t\x13\x02\t\x14\x02\x03.\x11\x03.\x12\x07\x06\x02\x033\x13\x03" +
"5\x14\x036\x15\x037\x16\x038\x17\x039\x18\x03:\x19";
"\x05\x07\x04\x02\x03\x1F\x06\x06\x02\x02\x03 \x07\x03!\b\x03\"\t\x03#" +
"\n\x03$\v\x03%\f\x03&\r\x03\'\x0E\x03(\x0F\x03)\x10\t\x12\x02\t\x13\x02" +
"\t\x14\x02\x03.\x11\x03.\x12\x07\x06\x02\x033\x13\x035\x14\x036\x15\x03" +
"7\x16\x038\x17\x039\x18\x03:\x19";
public static readonly _serializedATN: string = Utils.join(
[
LGTemplateLexer._serializedATNSegment0,
Expand Down
8 changes: 8 additions & 0 deletions libraries/botbuilder-lg/tests/lg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ describe('LG', function() {
evaled = templates.evaluate('template');
assert.strictEqual(evaled, 15);

evaled = templates.evaluate('crtObj');
assert.deepStrictEqual(evaled, {a: 1, c: 3, b: 2});

var evaledArray = templates.evaluate('crtArr');
assert.deepStrictEqual(evaledArray, [1, 2, 3, 4]);

var evaledMultilineResult = templates.evaluate('evalMultiLineObj');
assert.strictEqual(evaledMultilineResult, '{"a":1,"b":2,"c":{"d":4,"e":5}}');

});

Expand Down
21 changes: 21 additions & 0 deletions libraries/botbuilder-lg/tests/testData/examples/MultiLineExpr.lg
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,24 @@ createArray(
4,
5)
)}

#crtObj
- ${{a: 1, c
:3,
b:2
}}

#crtArr
- ${[1,2,
3,
4]}

#evalMultiLineObj
- ${string(
setProperty(
{a: 1,
b: 2},
'c',
{d: 4,
e: 5})
)}