-
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.
Browse files
Browse the repository at this point in the history
Bugfix/#487
- Loading branch information
Showing
12 changed files
with
453 additions
and
14 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
src/samples/HandMadeExpressions/Properties/launchSettings.json
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,11 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"profiles": { | ||
"BenchGenGen": { | ||
"commandName": "DebugRoslynComponent", | ||
"targetProject": "../BenchGen/BenchGen.csproj" | ||
} | ||
} | ||
} | ||
|
||
|
40 changes: 40 additions & 0 deletions
40
src/samples/HandMadeExpressions/sourceGenerator/SyntaxExtensions.cs
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,40 @@ | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
|
||
namespace handExpressions.sourceGenerator; | ||
|
||
public static class SyntaxExtensions | ||
{ | ||
public static string GetNameSpace(this SyntaxNode declarationSyntax) | ||
{ | ||
if (declarationSyntax.Parent is FileScopedNamespaceDeclarationSyntax fileScopedNamespace) | ||
{ | ||
return fileScopedNamespace.Name.ToString(); | ||
} | ||
else if (declarationSyntax.Parent is NamespaceDeclarationSyntax namespaceDeclaration) | ||
{ | ||
return namespaceDeclaration.Name.ToString(); | ||
} | ||
|
||
return string.Empty; | ||
} | ||
|
||
public static CompilationUnitSyntax GetCompilationUnit(this SyntaxNode syntaxNode) | ||
{ | ||
if (syntaxNode is CompilationUnitSyntax compilationUnitSyntax) | ||
{ | ||
return compilationUnitSyntax; | ||
} | ||
|
||
if (syntaxNode.Parent != null) | ||
{ | ||
return syntaxNode.Parent.GetCompilationUnit(); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
|
||
|
||
|
||
} |
Empty file.
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,118 @@ | ||
using sly.lexer; | ||
|
||
namespace ParserExample; | ||
|
||
public enum Issue487Token | ||
{ | ||
[Lexeme(GenericToken.UpTo, ">>", "??")] | ||
[Mode("xlmode", "dmode", "calcmode", "lvar")] | ||
[Pop] | ||
OPS = 103, | ||
|
||
#region default | ||
|
||
[Sugar(">>")] | ||
[Mode("default")] | ||
INSTALL = 15, | ||
|
||
// PUSHERS | ||
|
||
[Keyword("CC")] | ||
[Push("calcmode")] | ||
[Mode("default")] | ||
START_C = 102, | ||
|
||
[Keyword("XL")] | ||
[Push("xlmode")] | ||
[Mode("default")] | ||
START_X = 100, // I think rightmost operand need smaller priority than left operand. Or it'll be extracted last from the leftovers. (Moved from 102 to 53 and the right side finally pulled all of the necessary characters) | ||
|
||
[Sugar("@")] | ||
[Push("dmode")] | ||
[Mode("default")] | ||
START_D = 101, | ||
|
||
[Sugar("$")] | ||
[Push("lvar")] | ||
[Mode("default")] | ||
VARSTART = 60, | ||
|
||
[Keyword("Int")] | ||
[Keyword("String")] | ||
[Keyword("Optset")] | ||
[Keyword("Money")] | ||
[Keyword("Decimal")] | ||
[Keyword("EtnRef")] | ||
[Keyword("toconvert")] | ||
[Push("convert")] | ||
[Mode("default")] | ||
CONVERT = 62, | ||
|
||
// END PUSHERS | ||
|
||
[Sugar("??")] | ||
[Mode("default")] | ||
IFNULLTHEN = 49, | ||
|
||
[Sugar("{")] | ||
[Mode("default")] | ||
BLOCK_START = 50, | ||
|
||
[Sugar("}")] | ||
[Mode("default")] | ||
BLOCK_END = 48, | ||
|
||
[Sugar("(")] | ||
[Mode("default")] | ||
LPAREN = 40, | ||
|
||
[Sugar(")")] | ||
[Mode("default")] | ||
RPAREN = 41, | ||
|
||
|
||
|
||
|
||
|
||
|
||
[String("\"", "\\")] | ||
CONST_BLOCK = 31, | ||
|
||
[AlphaId] | ||
LOCALVAR = 61, | ||
|
||
EOF = 0, | ||
|
||
#endregion | ||
|
||
#region dmode | ||
|
||
|
||
#endregion | ||
|
||
|
||
|
||
#region convert | ||
|
||
|
||
|
||
[Sugar(":")] | ||
[Mode("convert")] | ||
[Pop] | ||
COLON = 43, | ||
|
||
|
||
|
||
[Sugar("?")] | ||
[Mode("convert")] | ||
ISNULLABLE = 105, | ||
|
||
|
||
#endregion | ||
|
||
|
||
|
||
|
||
|
||
|
||
} |
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
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
Oops, something went wrong.