-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of github.com:b3b00/csly into dev
* 'dev' of github.com:b3b00/csly: Update README.md Update README.md #165 fix issues after @CP3088 pull-request Optimized Expression Rules for #165 looking at #165
- Loading branch information
Showing
8 changed files
with
216 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using sly.lexer; | ||
|
||
namespace ParserExample | ||
{ | ||
public enum Issue165Lexer | ||
{ | ||
[Lexeme(GenericToken.SugarToken,"?")] | ||
QUESTIONMARK = 1, | ||
|
||
[Lexeme(GenericToken.SugarToken,"+")] | ||
PLUS = 2, | ||
|
||
[Lexeme(GenericToken.SugarToken,"-")] | ||
MINUS = 3, | ||
|
||
[Lexeme(GenericToken.SugarToken,"*")] | ||
TIMES = 4, | ||
|
||
[Lexeme(GenericToken.SugarToken,"/")] | ||
DIVIDE = 5, | ||
|
||
[Lexeme(GenericToken.SugarToken,"(")] | ||
LPAR = 6, | ||
|
||
[Lexeme(GenericToken.SugarToken,")")] | ||
RPAR = 6, | ||
|
||
[Lexeme(GenericToken.SugarToken,"[")] | ||
LBR = 7, | ||
|
||
[Lexeme(GenericToken.SugarToken,"]")] | ||
RBR = 8, | ||
|
||
[Lexeme(GenericToken.SugarToken,":")] | ||
COLON = 7, | ||
|
||
[Lexeme(GenericToken.SugarToken,"=")] | ||
EQ = 8, | ||
|
||
|
||
[Lexeme(GenericToken.Identifier)] ID = 20, | ||
|
||
[Lexeme(GenericToken.String)] STRING = 21, | ||
|
||
[Lexeme(GenericToken.Int)] INT = 22, | ||
|
||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
using expressionparser; | ||
using sly.lexer; | ||
using sly.parser.generator; | ||
|
||
namespace ParserExample | ||
{ | ||
public class Issue165Parser | ||
{ | ||
|
||
[Production("test_stmt : ID EQ [d] arith_expr ")] | ||
public object assign(Token<Issue165Lexer> id, object expr) | ||
{ | ||
return null; | ||
} | ||
|
||
|
||
|
||
[Operation((int) Issue165Lexer.PLUS, Affix.InFix, Associativity.Right, 10)] | ||
[Operation("MINUS", Affix.InFix, Associativity.Left, 10)] | ||
public object BinaryTermExpression(object left, Token<Issue165Lexer> operation, object right) | ||
{ | ||
return null; | ||
} | ||
|
||
|
||
[Operation((int) Issue165Lexer.TIMES, Affix.InFix, Associativity.Right, 50)] | ||
[Operation("DIVIDE", Affix.InFix, Associativity.Left, 50)] | ||
public object BinaryFactorExpression(double left, Token<Issue165Lexer> operation, object right) | ||
{ | ||
|
||
return null; | ||
} | ||
|
||
|
||
|
||
[Production("arith_expr : Issue165Parser_expressions")] | ||
[Production("arith_expr : ternary_expr")] | ||
public object arith(object h) | ||
{ | ||
return h; | ||
} | ||
|
||
[Production( | ||
"ternary_expr : Issue165Parser_expressions QUESTIONMARK [d] Issue165Parser_expressions COLON [d] Issue165Parser_expressions")] | ||
public object ternary(object j, object k, object l) | ||
{ | ||
return null; | ||
} | ||
|
||
[Production("sqbr_expr : ID LBR [d] Issue165Parser_expressions RBR [d]")] | ||
public object sqrbrack(Token<Issue165Lexer> token, object expr) | ||
{ | ||
return null; | ||
} | ||
|
||
[Production("group_expr : LPAR [d] Issue165Parser_expressions RPAR [d]")] | ||
public object group(object subexpr) | ||
{ | ||
return subexpr; | ||
} | ||
|
||
[Operand] | ||
[Production("atom : ID")] | ||
public object id(Token<Issue165Lexer> i) | ||
{ | ||
return null; | ||
} | ||
[Operand] | ||
[Production("atom : INT")] | ||
public object integer(Token<Issue165Lexer> i) | ||
{ | ||
return i; | ||
} | ||
[Operand] | ||
[Production("atom : sqbr_expr")] | ||
public object sq(object i) | ||
{ | ||
return i; | ||
} | ||
[Operand] | ||
[Production("atom : group_expr")] | ||
public object id(object g) | ||
{ | ||
return g; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters