-
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.
- Loading branch information
Showing
8 changed files
with
88 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using sly.lexer; | ||
|
||
namespace ParserExample; | ||
|
||
public enum ExprLexer | ||
{ | ||
[Double] | ||
NUMBER, | ||
[Sugar("+")] | ||
PLUS, | ||
[Sugar("-")] | ||
MINUS, | ||
[Sugar("*")] | ||
TIMES, | ||
[Sugar("/")] | ||
DIVIDE, | ||
[Sugar("(")] | ||
LPAREN, | ||
[Sugar(")")] | ||
RPAREN, | ||
} |
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,58 @@ | ||
using sly.lexer; | ||
using sly.parser.generator; | ||
|
||
namespace ParserExample; | ||
|
||
[ParserRoot("root")] | ||
public class ExprParser | ||
{ | ||
[Production("root : ExprParser_expressions")] | ||
public object root___WhileParser_expressions(object p0) | ||
{ | ||
return default(object); | ||
} | ||
|
||
[Infix("PLUS", Associativity.Right, 10)] | ||
public object PLUS(object left, Token<ExprLexer> oper, object right) | ||
{ | ||
return left; | ||
} | ||
|
||
[Infix("MINUS", Associativity.Left, 10)] | ||
public object MINUS(object left, Token<ExprLexer> oper, object right) | ||
{ | ||
return left; | ||
} | ||
|
||
[Infix("TIMES", Associativity.Right, 50)] | ||
public object TIMES(object left, Token<ExprLexer> oper, object right) | ||
{ | ||
return left; | ||
} | ||
|
||
[Infix("DIVIDE", Associativity.Left, 50)] | ||
public object DIVIDE(object left, Token<ExprLexer> oper, object right) | ||
{ | ||
return left; | ||
} | ||
|
||
[Prefix("MINUS", Associativity.Left, 100)] | ||
public object MINUS(Token<ExprLexer> oper, object value) | ||
{ | ||
return value; | ||
} | ||
|
||
[Operand] | ||
[Production("operand : NUMBER")] | ||
public object operand___NUMBER(Token<ExprLexer> p0) | ||
{ | ||
return default(object); | ||
} | ||
|
||
[Operand] | ||
[Production("operand : LPAREN ExprParser_expressions RPAREN")] | ||
public object operand___LPAREN_WhileParser_expressions_RPAREN(Token<ExprLexer> p0, object p1, Token<ExprLexer> p2) | ||
{ | ||
return default(object); | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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