diff --git a/src/parser/LatexParser.g4 b/src/parser/LatexParser.g4 index d49bdc12..3f1e6866 100644 --- a/src/parser/LatexParser.g4 +++ b/src/parser/LatexParser.g4 @@ -6,7 +6,7 @@ statement: (assign | assign_list | assign_plus_query | query | equality | u_block | number | id | id_list | guess | guess_list | expr | condition | piecewise_assign | insert_matrix | scatter_plot_query)? EOF; -scatter_plot_query: (( L_PAREN id COMMA id R_PAREN ) | ( id COMMA id )) AS_LINES? EQ (( L_PAREN u_block COMMA u_block R_PAREN ) | ( u_block COMMA u_block ))?; +scatter_plot_query: (( L_PAREN expr COMMA expr R_PAREN ) | ( expr COMMA expr )) AS_LINES? EQ (( L_PAREN u_block COMMA u_block R_PAREN ) | ( u_block COMMA u_block ))?; insert_matrix: .*? (u_insert_matrix .*?)+; diff --git a/src/parser/LatexParser.ts b/src/parser/LatexParser.ts index f3e18fa9..4bffbb64 100644 --- a/src/parser/LatexParser.ts +++ b/src/parser/LatexParser.ts @@ -436,37 +436,35 @@ export default class LatexParser extends Parser { { this.state = 96; this._errHandler.sync(this); - switch (this._input.LA(1)) { - case 6: + switch ( this._interp.adaptivePredict(this._input, 1, this._ctx) ) { + case 1: { { this.state = 86; this.match(LatexParser.L_PAREN); this.state = 87; - this.id(); + this.expr(0); this.state = 88; this.match(LatexParser.COMMA); this.state = 89; - this.id(); + this.expr(0); this.state = 90; this.match(LatexParser.R_PAREN); } } break; - case 69: + case 2: { { this.state = 92; - this.id(); + this.expr(0); this.state = 93; this.match(LatexParser.COMMA); this.state = 94; - this.id(); + this.expr(0); } } break; - default: - throw new NoViableAltException(this); } this.state = 99; this._errHandler.sync(this); @@ -3315,137 +3313,137 @@ export default class LatexParser extends Parser { 1,0,0,0,82,70,1,0,0,0,82,71,1,0,0,0,82,72,1,0,0,0,82,73,1,0,0,0,82,74,1, 0,0,0,82,75,1,0,0,0,82,76,1,0,0,0,82,77,1,0,0,0,82,78,1,0,0,0,82,79,1,0, 0,0,82,80,1,0,0,0,82,81,1,0,0,0,82,83,1,0,0,0,83,84,1,0,0,0,84,85,5,0,0, - 1,85,1,1,0,0,0,86,87,5,6,0,0,87,88,3,6,3,0,88,89,5,59,0,0,89,90,3,6,3,0, - 90,91,5,7,0,0,91,97,1,0,0,0,92,93,3,6,3,0,93,94,5,59,0,0,94,95,3,6,3,0, - 95,97,1,0,0,0,96,86,1,0,0,0,96,92,1,0,0,0,97,99,1,0,0,0,98,100,5,28,0,0, - 99,98,1,0,0,0,99,100,1,0,0,0,100,101,1,0,0,0,101,112,5,54,0,0,102,103,5, - 6,0,0,103,104,3,58,29,0,104,105,5,59,0,0,105,106,3,58,29,0,106,107,5,7, - 0,0,107,113,1,0,0,0,108,109,3,58,29,0,109,110,5,59,0,0,110,111,3,58,29, - 0,111,113,1,0,0,0,112,102,1,0,0,0,112,108,1,0,0,0,112,113,1,0,0,0,113,3, - 1,0,0,0,114,116,9,0,0,0,115,114,1,0,0,0,116,119,1,0,0,0,117,118,1,0,0,0, - 117,115,1,0,0,0,118,127,1,0,0,0,119,117,1,0,0,0,120,124,3,60,30,0,121,123, - 9,0,0,0,122,121,1,0,0,0,123,126,1,0,0,0,124,125,1,0,0,0,124,122,1,0,0,0, - 125,128,1,0,0,0,126,124,1,0,0,0,127,120,1,0,0,0,128,129,1,0,0,0,129,127, - 1,0,0,0,129,130,1,0,0,0,130,5,1,0,0,0,131,132,5,69,0,0,132,7,1,0,0,0,133, - 135,5,52,0,0,134,133,1,0,0,0,134,135,1,0,0,0,135,136,1,0,0,0,136,137,5, - 62,0,0,137,9,1,0,0,0,138,139,3,8,4,0,139,140,3,58,29,0,140,11,1,0,0,0,141, - 144,3,6,3,0,142,144,5,11,0,0,143,141,1,0,0,0,143,142,1,0,0,0,144,145,1, - 0,0,0,145,146,5,54,0,0,146,147,3,56,28,0,147,13,1,0,0,0,148,151,3,12,6, - 0,149,150,5,59,0,0,150,152,3,12,6,0,151,149,1,0,0,0,152,153,1,0,0,0,153, - 151,1,0,0,0,153,154,1,0,0,0,154,15,1,0,0,0,155,156,3,12,6,0,156,158,5,54, - 0,0,157,159,3,58,29,0,158,157,1,0,0,0,158,159,1,0,0,0,159,17,1,0,0,0,160, - 161,3,56,28,0,161,163,5,54,0,0,162,164,3,58,29,0,163,162,1,0,0,0,163,164, - 1,0,0,0,164,19,1,0,0,0,165,166,3,56,28,0,166,167,5,54,0,0,167,168,3,56, - 28,0,168,21,1,0,0,0,169,172,3,6,3,0,170,172,5,11,0,0,171,169,1,0,0,0,171, - 170,1,0,0,0,172,173,1,0,0,0,173,174,5,54,0,0,174,175,3,6,3,0,175,176,5, - 6,0,0,176,181,3,24,12,0,177,178,5,59,0,0,178,180,3,24,12,0,179,177,1,0, - 0,0,180,183,1,0,0,0,181,179,1,0,0,0,181,182,1,0,0,0,182,184,1,0,0,0,183, - 181,1,0,0,0,184,185,5,7,0,0,185,23,1,0,0,0,186,187,5,6,0,0,187,188,3,56, - 28,0,188,189,5,59,0,0,189,190,3,38,19,0,190,191,5,7,0,0,191,25,1,0,0,0, - 192,194,5,27,0,0,193,192,1,0,0,0,193,194,1,0,0,0,194,195,1,0,0,0,195,196, - 7,0,0,0,196,197,5,6,0,0,197,198,3,56,28,0,198,199,5,7,0,0,199,27,1,0,0, - 0,200,208,5,12,0,0,201,202,5,13,0,0,202,203,5,4,0,0,203,204,5,5,0,0,204, - 205,5,53,0,0,205,206,5,4,0,0,206,208,5,5,0,0,207,200,1,0,0,0,207,201,1, - 0,0,0,208,209,1,0,0,0,209,210,5,6,0,0,210,211,3,56,28,0,211,218,5,7,0,0, - 212,213,5,16,0,0,213,214,5,4,0,0,214,215,3,6,3,0,215,216,5,5,0,0,216,219, - 1,0,0,0,217,219,3,6,3,0,218,212,1,0,0,0,218,217,1,0,0,0,219,220,1,0,0,0, - 220,221,5,6,0,0,221,222,3,6,3,0,222,223,5,7,0,0,223,29,1,0,0,0,224,225, - 5,13,0,0,225,226,5,4,0,0,226,227,3,56,28,0,227,228,5,5,0,0,228,231,1,0, - 0,0,229,231,7,1,0,0,230,224,1,0,0,0,230,229,1,0,0,0,231,238,1,0,0,0,232, - 233,5,53,0,0,233,234,5,4,0,0,234,235,3,56,28,0,235,236,5,5,0,0,236,239, - 1,0,0,0,237,239,7,2,0,0,238,232,1,0,0,0,238,237,1,0,0,0,239,240,1,0,0,0, - 240,241,5,6,0,0,241,242,3,56,28,0,242,249,5,7,0,0,243,244,5,16,0,0,244, - 245,5,4,0,0,245,246,3,6,3,0,246,247,5,5,0,0,247,250,1,0,0,0,248,250,3,6, - 3,0,249,243,1,0,0,0,249,248,1,0,0,0,250,251,1,0,0,0,251,252,5,6,0,0,252, - 253,3,6,3,0,253,254,5,7,0,0,254,31,1,0,0,0,255,256,5,17,0,0,256,263,5,4, - 0,0,257,258,5,16,0,0,258,259,5,4,0,0,259,260,3,6,3,0,260,261,5,5,0,0,261, - 264,1,0,0,0,262,264,3,6,3,0,263,257,1,0,0,0,263,262,1,0,0,0,264,265,1,0, - 0,0,265,266,5,5,0,0,266,273,5,4,0,0,267,268,5,16,0,0,268,269,5,4,0,0,269, - 270,3,6,3,0,270,271,5,5,0,0,271,274,1,0,0,0,272,274,3,6,3,0,273,267,1,0, - 0,0,273,272,1,0,0,0,274,275,1,0,0,0,275,276,5,6,0,0,276,277,3,6,3,0,277, - 278,5,7,0,0,278,279,5,5,0,0,279,280,5,6,0,0,280,281,3,56,28,0,281,282,5, - 7,0,0,282,33,1,0,0,0,283,284,5,17,0,0,284,291,5,4,0,0,285,286,5,16,0,0, - 286,287,5,4,0,0,287,288,3,6,3,0,288,289,5,5,0,0,289,292,1,0,0,0,290,292, - 3,6,3,0,291,285,1,0,0,0,291,290,1,0,0,0,292,299,1,0,0,0,293,294,5,53,0, - 0,294,295,5,4,0,0,295,296,3,8,4,0,296,297,5,5,0,0,297,300,1,0,0,0,298,300, - 5,60,0,0,299,293,1,0,0,0,299,298,1,0,0,0,300,301,1,0,0,0,301,302,5,5,0, - 0,302,309,5,4,0,0,303,304,5,16,0,0,304,305,5,4,0,0,305,306,3,6,3,0,306, - 307,5,5,0,0,307,310,1,0,0,0,308,310,3,6,3,0,309,303,1,0,0,0,309,308,1,0, - 0,0,310,311,1,0,0,0,311,312,5,6,0,0,312,313,3,6,3,0,313,320,5,7,0,0,314, - 315,5,53,0,0,315,316,5,4,0,0,316,317,3,8,4,0,317,318,5,5,0,0,318,321,1, - 0,0,0,319,321,5,60,0,0,320,314,1,0,0,0,320,319,1,0,0,0,321,322,1,0,0,0, - 322,323,5,5,0,0,323,324,5,6,0,0,324,325,3,56,28,0,325,326,5,7,0,0,326,35, - 1,0,0,0,327,328,3,6,3,0,328,329,5,54,0,0,329,330,3,56,28,0,330,338,1,0, - 0,0,331,332,3,56,28,0,332,333,7,3,0,0,333,334,3,6,3,0,334,335,7,3,0,0,335, - 336,3,56,28,0,336,338,1,0,0,0,337,327,1,0,0,0,337,331,1,0,0,0,338,37,1, - 0,0,0,339,342,3,46,23,0,340,342,3,48,24,0,341,339,1,0,0,0,341,340,1,0,0, - 0,342,39,1,0,0,0,343,346,3,6,3,0,344,345,5,59,0,0,345,347,3,6,3,0,346,344, - 1,0,0,0,347,348,1,0,0,0,348,346,1,0,0,0,348,349,1,0,0,0,349,41,1,0,0,0, - 350,351,3,6,3,0,351,354,7,4,0,0,352,355,3,8,4,0,353,355,3,10,5,0,354,352, - 1,0,0,0,354,353,1,0,0,0,355,43,1,0,0,0,356,359,3,42,21,0,357,358,5,59,0, - 0,358,360,3,42,21,0,359,357,1,0,0,0,360,361,1,0,0,0,361,359,1,0,0,0,361, - 362,1,0,0,0,362,45,1,0,0,0,363,364,3,56,28,0,364,365,7,5,0,0,365,366,3, - 56,28,0,366,47,1,0,0,0,367,368,3,56,28,0,368,369,7,5,0,0,369,370,3,56,28, - 0,370,371,7,5,0,0,371,372,3,56,28,0,372,49,1,0,0,0,373,378,3,56,28,0,374, - 375,5,65,0,0,375,377,3,56,28,0,376,374,1,0,0,0,377,380,1,0,0,0,378,376, - 1,0,0,0,378,379,1,0,0,0,379,51,1,0,0,0,380,378,1,0,0,0,381,382,3,6,3,0, - 382,383,5,6,0,0,383,388,3,36,18,0,384,385,5,59,0,0,385,387,3,36,18,0,386, - 384,1,0,0,0,387,390,1,0,0,0,388,386,1,0,0,0,388,389,1,0,0,0,389,391,1,0, - 0,0,390,388,1,0,0,0,391,396,5,7,0,0,392,393,5,69,0,0,393,394,3,8,4,0,394, - 395,5,69,0,0,395,397,1,0,0,0,396,392,1,0,0,0,396,397,1,0,0,0,397,53,1,0, - 0,0,398,399,5,16,0,0,399,400,5,4,0,0,400,401,3,6,3,0,401,402,5,5,0,0,402, - 405,1,0,0,0,403,405,3,6,3,0,404,398,1,0,0,0,404,403,1,0,0,0,405,406,1,0, - 0,0,406,407,5,6,0,0,407,412,3,56,28,0,408,409,5,59,0,0,409,411,3,56,28, - 0,410,408,1,0,0,0,411,414,1,0,0,0,412,410,1,0,0,0,412,413,1,0,0,0,413,415, - 1,0,0,0,414,412,1,0,0,0,415,416,5,7,0,0,416,55,1,0,0,0,417,418,6,28,-1, - 0,418,419,3,6,3,0,419,420,5,68,0,0,420,526,1,0,0,0,421,422,3,6,3,0,422, - 423,7,2,0,0,423,424,5,67,0,0,424,526,1,0,0,0,425,426,3,6,3,0,426,427,5, - 53,0,0,427,428,5,4,0,0,428,429,3,56,28,0,429,430,5,5,0,0,430,431,5,67,0, - 0,431,526,1,0,0,0,432,526,5,22,0,0,433,434,5,21,0,0,434,435,5,4,0,0,435, - 436,3,56,28,0,436,437,5,5,0,0,437,526,1,0,0,0,438,439,5,63,0,0,439,444, - 3,50,25,0,440,441,5,66,0,0,441,443,3,50,25,0,442,440,1,0,0,0,443,446,1, - 0,0,0,444,442,1,0,0,0,444,445,1,0,0,0,445,447,1,0,0,0,446,444,1,0,0,0,447, - 448,5,64,0,0,448,526,1,0,0,0,449,526,3,26,13,0,450,526,3,28,14,0,451,526, - 3,30,15,0,452,526,3,32,16,0,453,526,3,34,17,0,454,456,5,27,0,0,455,454, - 1,0,0,0,455,456,1,0,0,0,456,457,1,0,0,0,457,458,5,42,0,0,458,459,5,6,0, - 0,459,460,3,56,28,0,460,461,5,7,0,0,461,526,1,0,0,0,462,464,5,27,0,0,463, - 462,1,0,0,0,463,464,1,0,0,0,464,465,1,0,0,0,465,466,5,43,0,0,466,467,5, - 6,0,0,467,468,3,56,28,0,468,469,5,7,0,0,469,526,1,0,0,0,470,471,5,44,0, - 0,471,472,5,4,0,0,472,473,3,56,28,0,473,474,5,5,0,0,474,475,5,6,0,0,475, - 476,3,56,28,0,476,477,5,7,0,0,477,526,1,0,0,0,478,479,7,6,0,0,479,480,5, - 6,0,0,480,481,3,56,28,0,481,482,5,7,0,0,482,526,1,0,0,0,483,484,5,9,0,0, - 484,485,3,56,28,0,485,486,5,9,0,0,486,526,1,0,0,0,487,488,5,8,0,0,488,489, - 3,56,28,0,489,490,5,8,0,0,490,526,1,0,0,0,491,526,3,10,5,0,492,526,3,8, - 4,0,493,494,5,52,0,0,494,526,3,56,28,29,495,496,5,17,0,0,496,497,5,4,0, - 0,497,498,3,56,28,0,498,499,5,5,0,0,499,500,5,4,0,0,500,501,3,56,28,0,501, - 502,5,5,0,0,502,526,1,0,0,0,503,526,5,18,0,0,504,526,3,6,3,0,505,526,3, - 52,26,0,506,526,3,54,27,0,507,526,5,11,0,0,508,509,5,6,0,0,509,510,3,56, - 28,0,510,511,5,7,0,0,511,526,1,0,0,0,512,513,3,8,4,0,513,514,3,56,28,11, - 514,526,1,0,0,0,515,516,3,10,5,0,516,517,3,56,28,10,517,526,1,0,0,0,518, - 519,5,11,0,0,519,526,3,56,28,9,520,523,5,25,0,0,521,522,5,4,0,0,522,524, - 5,5,0,0,523,521,1,0,0,0,523,524,1,0,0,0,524,526,1,0,0,0,525,417,1,0,0,0, - 525,421,1,0,0,0,525,425,1,0,0,0,525,432,1,0,0,0,525,433,1,0,0,0,525,438, - 1,0,0,0,525,449,1,0,0,0,525,450,1,0,0,0,525,451,1,0,0,0,525,452,1,0,0,0, - 525,453,1,0,0,0,525,455,1,0,0,0,525,463,1,0,0,0,525,470,1,0,0,0,525,478, - 1,0,0,0,525,483,1,0,0,0,525,487,1,0,0,0,525,491,1,0,0,0,525,492,1,0,0,0, - 525,493,1,0,0,0,525,495,1,0,0,0,525,503,1,0,0,0,525,504,1,0,0,0,525,505, - 1,0,0,0,525,506,1,0,0,0,525,507,1,0,0,0,525,508,1,0,0,0,525,512,1,0,0,0, - 525,515,1,0,0,0,525,518,1,0,0,0,525,520,1,0,0,0,526,589,1,0,0,0,527,528, - 10,28,0,0,528,529,5,20,0,0,529,588,3,56,28,29,530,531,10,27,0,0,531,532, - 5,19,0,0,532,588,3,56,28,28,533,534,10,24,0,0,534,535,5,52,0,0,535,588, - 3,56,28,25,536,537,10,23,0,0,537,538,5,51,0,0,538,588,3,56,28,24,539,540, - 10,49,0,0,540,588,7,2,0,0,541,542,10,48,0,0,542,543,5,53,0,0,543,544,5, - 4,0,0,544,545,3,56,28,0,545,546,5,5,0,0,546,588,1,0,0,0,547,548,10,47,0, - 0,548,549,5,10,0,0,549,550,5,4,0,0,550,551,3,56,28,0,551,552,5,59,0,0,552, - 553,3,56,28,0,553,554,5,5,0,0,554,588,1,0,0,0,555,556,10,46,0,0,556,588, - 5,26,0,0,557,558,10,17,0,0,558,559,5,10,0,0,559,560,5,4,0,0,560,588,5,5, - 0,0,561,562,10,16,0,0,562,563,5,53,0,0,563,564,5,4,0,0,564,588,5,5,0,0, - 565,566,10,15,0,0,566,588,3,6,3,0,567,568,10,14,0,0,568,588,3,8,4,0,569, - 570,10,13,0,0,570,588,3,10,5,0,571,572,10,12,0,0,572,588,5,11,0,0,573,574, - 10,8,0,0,574,588,3,52,26,0,575,576,10,7,0,0,576,588,3,54,27,0,577,578,10, - 6,0,0,578,588,3,26,13,0,579,580,10,5,0,0,580,588,3,28,14,0,581,582,10,4, - 0,0,582,588,3,30,15,0,583,584,10,3,0,0,584,588,3,32,16,0,585,586,10,2,0, - 0,586,588,3,34,17,0,587,527,1,0,0,0,587,530,1,0,0,0,587,533,1,0,0,0,587, + 1,85,1,1,0,0,0,86,87,5,6,0,0,87,88,3,56,28,0,88,89,5,59,0,0,89,90,3,56, + 28,0,90,91,5,7,0,0,91,97,1,0,0,0,92,93,3,56,28,0,93,94,5,59,0,0,94,95,3, + 56,28,0,95,97,1,0,0,0,96,86,1,0,0,0,96,92,1,0,0,0,97,99,1,0,0,0,98,100, + 5,28,0,0,99,98,1,0,0,0,99,100,1,0,0,0,100,101,1,0,0,0,101,112,5,54,0,0, + 102,103,5,6,0,0,103,104,3,58,29,0,104,105,5,59,0,0,105,106,3,58,29,0,106, + 107,5,7,0,0,107,113,1,0,0,0,108,109,3,58,29,0,109,110,5,59,0,0,110,111, + 3,58,29,0,111,113,1,0,0,0,112,102,1,0,0,0,112,108,1,0,0,0,112,113,1,0,0, + 0,113,3,1,0,0,0,114,116,9,0,0,0,115,114,1,0,0,0,116,119,1,0,0,0,117,118, + 1,0,0,0,117,115,1,0,0,0,118,127,1,0,0,0,119,117,1,0,0,0,120,124,3,60,30, + 0,121,123,9,0,0,0,122,121,1,0,0,0,123,126,1,0,0,0,124,125,1,0,0,0,124,122, + 1,0,0,0,125,128,1,0,0,0,126,124,1,0,0,0,127,120,1,0,0,0,128,129,1,0,0,0, + 129,127,1,0,0,0,129,130,1,0,0,0,130,5,1,0,0,0,131,132,5,69,0,0,132,7,1, + 0,0,0,133,135,5,52,0,0,134,133,1,0,0,0,134,135,1,0,0,0,135,136,1,0,0,0, + 136,137,5,62,0,0,137,9,1,0,0,0,138,139,3,8,4,0,139,140,3,58,29,0,140,11, + 1,0,0,0,141,144,3,6,3,0,142,144,5,11,0,0,143,141,1,0,0,0,143,142,1,0,0, + 0,144,145,1,0,0,0,145,146,5,54,0,0,146,147,3,56,28,0,147,13,1,0,0,0,148, + 151,3,12,6,0,149,150,5,59,0,0,150,152,3,12,6,0,151,149,1,0,0,0,152,153, + 1,0,0,0,153,151,1,0,0,0,153,154,1,0,0,0,154,15,1,0,0,0,155,156,3,12,6,0, + 156,158,5,54,0,0,157,159,3,58,29,0,158,157,1,0,0,0,158,159,1,0,0,0,159, + 17,1,0,0,0,160,161,3,56,28,0,161,163,5,54,0,0,162,164,3,58,29,0,163,162, + 1,0,0,0,163,164,1,0,0,0,164,19,1,0,0,0,165,166,3,56,28,0,166,167,5,54,0, + 0,167,168,3,56,28,0,168,21,1,0,0,0,169,172,3,6,3,0,170,172,5,11,0,0,171, + 169,1,0,0,0,171,170,1,0,0,0,172,173,1,0,0,0,173,174,5,54,0,0,174,175,3, + 6,3,0,175,176,5,6,0,0,176,181,3,24,12,0,177,178,5,59,0,0,178,180,3,24,12, + 0,179,177,1,0,0,0,180,183,1,0,0,0,181,179,1,0,0,0,181,182,1,0,0,0,182,184, + 1,0,0,0,183,181,1,0,0,0,184,185,5,7,0,0,185,23,1,0,0,0,186,187,5,6,0,0, + 187,188,3,56,28,0,188,189,5,59,0,0,189,190,3,38,19,0,190,191,5,7,0,0,191, + 25,1,0,0,0,192,194,5,27,0,0,193,192,1,0,0,0,193,194,1,0,0,0,194,195,1,0, + 0,0,195,196,7,0,0,0,196,197,5,6,0,0,197,198,3,56,28,0,198,199,5,7,0,0,199, + 27,1,0,0,0,200,208,5,12,0,0,201,202,5,13,0,0,202,203,5,4,0,0,203,204,5, + 5,0,0,204,205,5,53,0,0,205,206,5,4,0,0,206,208,5,5,0,0,207,200,1,0,0,0, + 207,201,1,0,0,0,208,209,1,0,0,0,209,210,5,6,0,0,210,211,3,56,28,0,211,218, + 5,7,0,0,212,213,5,16,0,0,213,214,5,4,0,0,214,215,3,6,3,0,215,216,5,5,0, + 0,216,219,1,0,0,0,217,219,3,6,3,0,218,212,1,0,0,0,218,217,1,0,0,0,219,220, + 1,0,0,0,220,221,5,6,0,0,221,222,3,6,3,0,222,223,5,7,0,0,223,29,1,0,0,0, + 224,225,5,13,0,0,225,226,5,4,0,0,226,227,3,56,28,0,227,228,5,5,0,0,228, + 231,1,0,0,0,229,231,7,1,0,0,230,224,1,0,0,0,230,229,1,0,0,0,231,238,1,0, + 0,0,232,233,5,53,0,0,233,234,5,4,0,0,234,235,3,56,28,0,235,236,5,5,0,0, + 236,239,1,0,0,0,237,239,7,2,0,0,238,232,1,0,0,0,238,237,1,0,0,0,239,240, + 1,0,0,0,240,241,5,6,0,0,241,242,3,56,28,0,242,249,5,7,0,0,243,244,5,16, + 0,0,244,245,5,4,0,0,245,246,3,6,3,0,246,247,5,5,0,0,247,250,1,0,0,0,248, + 250,3,6,3,0,249,243,1,0,0,0,249,248,1,0,0,0,250,251,1,0,0,0,251,252,5,6, + 0,0,252,253,3,6,3,0,253,254,5,7,0,0,254,31,1,0,0,0,255,256,5,17,0,0,256, + 263,5,4,0,0,257,258,5,16,0,0,258,259,5,4,0,0,259,260,3,6,3,0,260,261,5, + 5,0,0,261,264,1,0,0,0,262,264,3,6,3,0,263,257,1,0,0,0,263,262,1,0,0,0,264, + 265,1,0,0,0,265,266,5,5,0,0,266,273,5,4,0,0,267,268,5,16,0,0,268,269,5, + 4,0,0,269,270,3,6,3,0,270,271,5,5,0,0,271,274,1,0,0,0,272,274,3,6,3,0,273, + 267,1,0,0,0,273,272,1,0,0,0,274,275,1,0,0,0,275,276,5,6,0,0,276,277,3,6, + 3,0,277,278,5,7,0,0,278,279,5,5,0,0,279,280,5,6,0,0,280,281,3,56,28,0,281, + 282,5,7,0,0,282,33,1,0,0,0,283,284,5,17,0,0,284,291,5,4,0,0,285,286,5,16, + 0,0,286,287,5,4,0,0,287,288,3,6,3,0,288,289,5,5,0,0,289,292,1,0,0,0,290, + 292,3,6,3,0,291,285,1,0,0,0,291,290,1,0,0,0,292,299,1,0,0,0,293,294,5,53, + 0,0,294,295,5,4,0,0,295,296,3,8,4,0,296,297,5,5,0,0,297,300,1,0,0,0,298, + 300,5,60,0,0,299,293,1,0,0,0,299,298,1,0,0,0,300,301,1,0,0,0,301,302,5, + 5,0,0,302,309,5,4,0,0,303,304,5,16,0,0,304,305,5,4,0,0,305,306,3,6,3,0, + 306,307,5,5,0,0,307,310,1,0,0,0,308,310,3,6,3,0,309,303,1,0,0,0,309,308, + 1,0,0,0,310,311,1,0,0,0,311,312,5,6,0,0,312,313,3,6,3,0,313,320,5,7,0,0, + 314,315,5,53,0,0,315,316,5,4,0,0,316,317,3,8,4,0,317,318,5,5,0,0,318,321, + 1,0,0,0,319,321,5,60,0,0,320,314,1,0,0,0,320,319,1,0,0,0,321,322,1,0,0, + 0,322,323,5,5,0,0,323,324,5,6,0,0,324,325,3,56,28,0,325,326,5,7,0,0,326, + 35,1,0,0,0,327,328,3,6,3,0,328,329,5,54,0,0,329,330,3,56,28,0,330,338,1, + 0,0,0,331,332,3,56,28,0,332,333,7,3,0,0,333,334,3,6,3,0,334,335,7,3,0,0, + 335,336,3,56,28,0,336,338,1,0,0,0,337,327,1,0,0,0,337,331,1,0,0,0,338,37, + 1,0,0,0,339,342,3,46,23,0,340,342,3,48,24,0,341,339,1,0,0,0,341,340,1,0, + 0,0,342,39,1,0,0,0,343,346,3,6,3,0,344,345,5,59,0,0,345,347,3,6,3,0,346, + 344,1,0,0,0,347,348,1,0,0,0,348,346,1,0,0,0,348,349,1,0,0,0,349,41,1,0, + 0,0,350,351,3,6,3,0,351,354,7,4,0,0,352,355,3,8,4,0,353,355,3,10,5,0,354, + 352,1,0,0,0,354,353,1,0,0,0,355,43,1,0,0,0,356,359,3,42,21,0,357,358,5, + 59,0,0,358,360,3,42,21,0,359,357,1,0,0,0,360,361,1,0,0,0,361,359,1,0,0, + 0,361,362,1,0,0,0,362,45,1,0,0,0,363,364,3,56,28,0,364,365,7,5,0,0,365, + 366,3,56,28,0,366,47,1,0,0,0,367,368,3,56,28,0,368,369,7,5,0,0,369,370, + 3,56,28,0,370,371,7,5,0,0,371,372,3,56,28,0,372,49,1,0,0,0,373,378,3,56, + 28,0,374,375,5,65,0,0,375,377,3,56,28,0,376,374,1,0,0,0,377,380,1,0,0,0, + 378,376,1,0,0,0,378,379,1,0,0,0,379,51,1,0,0,0,380,378,1,0,0,0,381,382, + 3,6,3,0,382,383,5,6,0,0,383,388,3,36,18,0,384,385,5,59,0,0,385,387,3,36, + 18,0,386,384,1,0,0,0,387,390,1,0,0,0,388,386,1,0,0,0,388,389,1,0,0,0,389, + 391,1,0,0,0,390,388,1,0,0,0,391,396,5,7,0,0,392,393,5,69,0,0,393,394,3, + 8,4,0,394,395,5,69,0,0,395,397,1,0,0,0,396,392,1,0,0,0,396,397,1,0,0,0, + 397,53,1,0,0,0,398,399,5,16,0,0,399,400,5,4,0,0,400,401,3,6,3,0,401,402, + 5,5,0,0,402,405,1,0,0,0,403,405,3,6,3,0,404,398,1,0,0,0,404,403,1,0,0,0, + 405,406,1,0,0,0,406,407,5,6,0,0,407,412,3,56,28,0,408,409,5,59,0,0,409, + 411,3,56,28,0,410,408,1,0,0,0,411,414,1,0,0,0,412,410,1,0,0,0,412,413,1, + 0,0,0,413,415,1,0,0,0,414,412,1,0,0,0,415,416,5,7,0,0,416,55,1,0,0,0,417, + 418,6,28,-1,0,418,419,3,6,3,0,419,420,5,68,0,0,420,526,1,0,0,0,421,422, + 3,6,3,0,422,423,7,2,0,0,423,424,5,67,0,0,424,526,1,0,0,0,425,426,3,6,3, + 0,426,427,5,53,0,0,427,428,5,4,0,0,428,429,3,56,28,0,429,430,5,5,0,0,430, + 431,5,67,0,0,431,526,1,0,0,0,432,526,5,22,0,0,433,434,5,21,0,0,434,435, + 5,4,0,0,435,436,3,56,28,0,436,437,5,5,0,0,437,526,1,0,0,0,438,439,5,63, + 0,0,439,444,3,50,25,0,440,441,5,66,0,0,441,443,3,50,25,0,442,440,1,0,0, + 0,443,446,1,0,0,0,444,442,1,0,0,0,444,445,1,0,0,0,445,447,1,0,0,0,446,444, + 1,0,0,0,447,448,5,64,0,0,448,526,1,0,0,0,449,526,3,26,13,0,450,526,3,28, + 14,0,451,526,3,30,15,0,452,526,3,32,16,0,453,526,3,34,17,0,454,456,5,27, + 0,0,455,454,1,0,0,0,455,456,1,0,0,0,456,457,1,0,0,0,457,458,5,42,0,0,458, + 459,5,6,0,0,459,460,3,56,28,0,460,461,5,7,0,0,461,526,1,0,0,0,462,464,5, + 27,0,0,463,462,1,0,0,0,463,464,1,0,0,0,464,465,1,0,0,0,465,466,5,43,0,0, + 466,467,5,6,0,0,467,468,3,56,28,0,468,469,5,7,0,0,469,526,1,0,0,0,470,471, + 5,44,0,0,471,472,5,4,0,0,472,473,3,56,28,0,473,474,5,5,0,0,474,475,5,6, + 0,0,475,476,3,56,28,0,476,477,5,7,0,0,477,526,1,0,0,0,478,479,7,6,0,0,479, + 480,5,6,0,0,480,481,3,56,28,0,481,482,5,7,0,0,482,526,1,0,0,0,483,484,5, + 9,0,0,484,485,3,56,28,0,485,486,5,9,0,0,486,526,1,0,0,0,487,488,5,8,0,0, + 488,489,3,56,28,0,489,490,5,8,0,0,490,526,1,0,0,0,491,526,3,10,5,0,492, + 526,3,8,4,0,493,494,5,52,0,0,494,526,3,56,28,29,495,496,5,17,0,0,496,497, + 5,4,0,0,497,498,3,56,28,0,498,499,5,5,0,0,499,500,5,4,0,0,500,501,3,56, + 28,0,501,502,5,5,0,0,502,526,1,0,0,0,503,526,5,18,0,0,504,526,3,6,3,0,505, + 526,3,52,26,0,506,526,3,54,27,0,507,526,5,11,0,0,508,509,5,6,0,0,509,510, + 3,56,28,0,510,511,5,7,0,0,511,526,1,0,0,0,512,513,3,8,4,0,513,514,3,56, + 28,11,514,526,1,0,0,0,515,516,3,10,5,0,516,517,3,56,28,10,517,526,1,0,0, + 0,518,519,5,11,0,0,519,526,3,56,28,9,520,523,5,25,0,0,521,522,5,4,0,0,522, + 524,5,5,0,0,523,521,1,0,0,0,523,524,1,0,0,0,524,526,1,0,0,0,525,417,1,0, + 0,0,525,421,1,0,0,0,525,425,1,0,0,0,525,432,1,0,0,0,525,433,1,0,0,0,525, + 438,1,0,0,0,525,449,1,0,0,0,525,450,1,0,0,0,525,451,1,0,0,0,525,452,1,0, + 0,0,525,453,1,0,0,0,525,455,1,0,0,0,525,463,1,0,0,0,525,470,1,0,0,0,525, + 478,1,0,0,0,525,483,1,0,0,0,525,487,1,0,0,0,525,491,1,0,0,0,525,492,1,0, + 0,0,525,493,1,0,0,0,525,495,1,0,0,0,525,503,1,0,0,0,525,504,1,0,0,0,525, + 505,1,0,0,0,525,506,1,0,0,0,525,507,1,0,0,0,525,508,1,0,0,0,525,512,1,0, + 0,0,525,515,1,0,0,0,525,518,1,0,0,0,525,520,1,0,0,0,526,589,1,0,0,0,527, + 528,10,28,0,0,528,529,5,20,0,0,529,588,3,56,28,29,530,531,10,27,0,0,531, + 532,5,19,0,0,532,588,3,56,28,28,533,534,10,24,0,0,534,535,5,52,0,0,535, + 588,3,56,28,25,536,537,10,23,0,0,537,538,5,51,0,0,538,588,3,56,28,24,539, + 540,10,49,0,0,540,588,7,2,0,0,541,542,10,48,0,0,542,543,5,53,0,0,543,544, + 5,4,0,0,544,545,3,56,28,0,545,546,5,5,0,0,546,588,1,0,0,0,547,548,10,47, + 0,0,548,549,5,10,0,0,549,550,5,4,0,0,550,551,3,56,28,0,551,552,5,59,0,0, + 552,553,3,56,28,0,553,554,5,5,0,0,554,588,1,0,0,0,555,556,10,46,0,0,556, + 588,5,26,0,0,557,558,10,17,0,0,558,559,5,10,0,0,559,560,5,4,0,0,560,588, + 5,5,0,0,561,562,10,16,0,0,562,563,5,53,0,0,563,564,5,4,0,0,564,588,5,5, + 0,0,565,566,10,15,0,0,566,588,3,6,3,0,567,568,10,14,0,0,568,588,3,8,4,0, + 569,570,10,13,0,0,570,588,3,10,5,0,571,572,10,12,0,0,572,588,5,11,0,0,573, + 574,10,8,0,0,574,588,3,52,26,0,575,576,10,7,0,0,576,588,3,54,27,0,577,578, + 10,6,0,0,578,588,3,26,13,0,579,580,10,5,0,0,580,588,3,28,14,0,581,582,10, + 4,0,0,582,588,3,30,15,0,583,584,10,3,0,0,584,588,3,32,16,0,585,586,10,2, + 0,0,586,588,3,34,17,0,587,527,1,0,0,0,587,530,1,0,0,0,587,533,1,0,0,0,587, 536,1,0,0,0,587,539,1,0,0,0,587,541,1,0,0,0,587,547,1,0,0,0,587,555,1,0, 0,0,587,557,1,0,0,0,587,561,1,0,0,0,587,565,1,0,0,0,587,567,1,0,0,0,587, 569,1,0,0,0,587,571,1,0,0,0,587,573,1,0,0,0,587,575,1,0,0,0,587,577,1,0, @@ -3574,11 +3572,11 @@ export class Scatter_plot_queryContext extends ParserRuleContext { public L_PAREN(i: number): TerminalNode { return this.getToken(LatexParser.L_PAREN, i); } - public id_list(): IdContext[] { - return this.getTypedRuleContexts(IdContext) as IdContext[]; + public expr_list(): ExprContext[] { + return this.getTypedRuleContexts(ExprContext) as ExprContext[]; } - public id(i: number): IdContext { - return this.getTypedRuleContext(IdContext, i) as IdContext; + public expr(i: number): ExprContext { + return this.getTypedRuleContext(ExprContext, i) as ExprContext; } public COMMA_list(): TerminalNode[] { return this.getTokens(LatexParser.COMMA); diff --git a/src/parser/LatexToSympy.ts b/src/parser/LatexToSympy.ts index 2111df9d..95229f82 100644 --- a/src/parser/LatexToSympy.ts +++ b/src/parser/LatexToSympy.ts @@ -13,27 +13,27 @@ import type { FieldTypes, Statement, QueryStatement, RangeQueryStatement, UserFu ScatterXValuesQueryStatement, ScatterYValuesQueryStatement} from "./types"; import { RESERVED, GREEK_CHARS, UNASSIGNABLE, COMPARISON_MAP, UNITS_WITH_OFFSET, TYPE_PARSING_ERRORS, BUILTIN_FUNCTION_MAP } from "./constants.js"; -import type { - GuessContext, Guess_listContext, IdContext, Id_listContext, - StatementContext, QueryContext, AssignContext, EqualityContext, PiExprContext, - ExponentContext, ArgumentContext, Builtin_functionContext, User_functionContext, - IndefiniteIntegralContext, Indefinite_integral_cmdContext, - Integral_cmdContext, IntegralContext, DerivativeContext, - Derivative_cmdContext, NDerivativeContext, N_derivative_cmdContext, - TrigFunctionContext, UnitExponentContext, UnitFractionalExponentContext, SqrtContext, - LnContext, LogContext, AbsContext, UnaryMinusContext, - BaseLogContext, UnitSqrtContext, MultiplyContext, UnitMultiplyContext, - DivideContext, UnitDivideContext, AddContext, - SubtractContext, VariableContext, Number_with_unitsContext, - NumberContext, NumberExprContext, NumberWithUnitsExprContext, - SubExprContext, UnitSubExprContext, UnitNameContext, - U_blockContext, Condition_singleContext, Condition_chainContext, - ConditionContext, Piecewise_argContext, Piecewise_assignContext, - Insert_matrixContext, BaseLogSingleCharContext, DivideIntsContext, - Assign_listContext, Assign_plus_queryContext, SingleIntSqrtContext, - MatrixContext, IndexContext, MatrixMultiplyContext, TransposeContext, NormContext, - EmptySubscriptContext, EmptySuperscriptContext, MissingMultiplicationContext, - BuiltinFunctionContext, UserFunctionContext, EmptyPlaceholderContext, Scatter_plot_queryContext +import { + type GuessContext, type Guess_listContext, IdContext, type Id_listContext, + type StatementContext, type QueryContext, type AssignContext, type EqualityContext, type PiExprContext, + type ExponentContext, type ArgumentContext, type Builtin_functionContext, type User_functionContext, + type IndefiniteIntegralContext, type Indefinite_integral_cmdContext, + type Integral_cmdContext, type IntegralContext, type DerivativeContext, + type Derivative_cmdContext, type NDerivativeContext, type N_derivative_cmdContext, + type TrigFunctionContext, type UnitExponentContext, type UnitFractionalExponentContext, type SqrtContext, + type LnContext, type LogContext, type AbsContext, type UnaryMinusContext, + type BaseLogContext, type UnitSqrtContext, type MultiplyContext, type UnitMultiplyContext, + type DivideContext, type UnitDivideContext, type AddContext, + type SubtractContext, type VariableContext, type Number_with_unitsContext, + type NumberContext, type NumberExprContext, type NumberWithUnitsExprContext, + type SubExprContext, type UnitSubExprContext, type UnitNameContext, + type U_blockContext, type Condition_singleContext, type Condition_chainContext, + type ConditionContext, type Piecewise_argContext, type Piecewise_assignContext, + type Insert_matrixContext, type BaseLogSingleCharContext, type DivideIntsContext, + type Assign_listContext, type Assign_plus_queryContext, type SingleIntSqrtContext, + type MatrixContext, type IndexContext, type MatrixMultiplyContext, type TransposeContext, type NormContext, + type EmptySubscriptContext, type EmptySuperscriptContext, type MissingMultiplicationContext, + type BuiltinFunctionContext, type UserFunctionContext, type EmptyPlaceholderContext, type Scatter_plot_queryContext } from "./LatexParser"; import { getBlankMatrixLatex } from "../utility"; @@ -588,19 +588,33 @@ export class LatexToSympy extends LatexParserVisitor { + let xName: string; + let yName: string; - const xName = this.visitId(ctx.id(0)); - const yName = this.visitId(ctx.id(1)); + let implicitParamsCursor = this.implicitParams.length; + let paramsCursor = this.params.length; + let exponentsCursor = this.exponents.length; + let functionsCursor = this.functions.length; + let argumentsCursor = this.arguments.length; + let localSubsCursor = this.localSubs.length; + + const xExpr = this.visit(ctx.expr(0)) as string; + + if (ctx.expr(0).children.length === 1 && ctx.expr(0).children[0] instanceof IdContext) { + xName = xExpr; + } else { + xName = "x"; + } const xValuesQuery: ScatterXValuesQueryStatement = { type: "query", equationIndex: this.equationIndex, - exponents: [], - implicitParams: [], - params: [xName], - functions: [], - arguments: [], - localSubs: [], + exponents: this.exponents.slice(exponentsCursor), + implicitParams: this.implicitParams.slice(implicitParamsCursor), + params: this.params.slice(paramsCursor), + functions: this.functions.slice(functionsCursor), + arguments: this.arguments.slice(argumentsCursor), + localSubs: this.localSubs.slice(localSubsCursor), units: "", unitsLatex: "", isExponent: false, @@ -611,21 +625,36 @@ export class LatexToSympy extends LatexParserVisitor