This repository has been archived by the owner on Oct 17, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for size function in domain expressions.
- Loading branch information
Jack Hughes
committed
Oct 3, 2017
1 parent
66dd308
commit a739979
Showing
42 changed files
with
845 additions
and
337 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 was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
src/Workbench.Core/Expressions/VariableDomainExpressionUnit.cs
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,57 @@ | ||
using Irony.Parsing; | ||
using Workbench.Core.Nodes; | ||
|
||
namespace Workbench.Core.Grammars | ||
{ | ||
/// <summary> | ||
/// Grammar for shared domain expressions. | ||
/// </summary> | ||
[Language("Domain Expression Grammar", "0.1", "A grammar for shared domain expressions.")] | ||
internal class DomainGrammarIrony : Grammar | ||
{ | ||
private const string FunctionNamePattern = @"\b[A-Za-z]\w*\b"; | ||
private const string FunctionArgumentStringLiteralPattern = @"\b[A-Za-z]\w*\b"; | ||
|
||
public DomainGrammarIrony() | ||
: base(caseSensitive: false) | ||
{ | ||
LanguageFlags = LanguageFlags.CreateAst | | ||
LanguageFlags.NewLineBeforeEOF; | ||
|
||
var RANGE = ToTerm("..", "range"); | ||
var FUNCTION_CALL_ARGUMENT_SEPERATOR = ToTerm(","); | ||
var OPEN_ARG = ToTerm("("); | ||
var CLOSE_ARG = ToTerm(")"); | ||
|
||
// Terminals | ||
var numberLiteral = new NumberLiteral("number literal", | ||
NumberOptions.IntOnly, | ||
typeof(NumberLiteralNode)); | ||
var functionCallArgumentStringLiteral = new RegexBasedTerminal("function call argument string literal", FunctionArgumentStringLiteralPattern); | ||
functionCallArgumentStringLiteral.AstConfig.NodeType = typeof(FunctionCallArgumentStringLiteralNode); | ||
var functionName = new RegexBasedTerminal("function name", FunctionNamePattern); | ||
functionName.AstConfig.NodeType = typeof(FunctionNameNode); | ||
|
||
// Non-terminals | ||
var domainExpression = new NonTerminal("domainExpression", typeof(DomainExpressionNode)); | ||
var bandExpression = new NonTerminal("expression", typeof(BandExpressionNode)); | ||
var functionCall = new NonTerminal("function call", typeof(FunctionCallXNode)); | ||
var functionCallArgumentList = new NonTerminal("function call arguments", typeof(FunctionArgumentListNode)); | ||
var functionCallArgument = new NonTerminal("function argument", typeof(FunctionCallArgumentNode)); | ||
|
||
// BNF rules | ||
functionCallArgument.Rule = numberLiteral | functionCallArgumentStringLiteral; | ||
functionCall.Rule = functionName + OPEN_ARG + functionCallArgumentList + CLOSE_ARG; | ||
functionCallArgumentList.Rule = MakePlusRule(functionCallArgumentList, FUNCTION_CALL_ARGUMENT_SEPERATOR, functionCallArgument); | ||
bandExpression.Rule = numberLiteral | functionCall; | ||
domainExpression.Rule = bandExpression + RANGE + bandExpression; | ||
|
||
Root = domainExpression; | ||
|
||
MarkPunctuation(RANGE, FUNCTION_CALL_ARGUMENT_SEPERATOR); | ||
MarkPunctuation(OPEN_ARG, CLOSE_ARG); | ||
|
||
RegisterBracePair("(", ")"); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,62 @@ | ||
using Irony.Parsing; | ||
using Workbench.Core.Nodes; | ||
|
||
namespace Workbench.Core.Grammars | ||
{ | ||
/// <summary> | ||
/// Grammar for variable inline domain expressions. | ||
/// </summary> | ||
[Language("Variable Domain Expression Grammar", "0.1", "A grammar for variable inline domain expressions.")] | ||
internal class VariableDomainGrammarIrony : Grammar | ||
{ | ||
private const string FunctionNamePattern = @"\b[A-Za-z]\w*\b"; | ||
private const string FunctionArgumentStringLiteralPattern = @"\b[A-Za-z]\w*\b"; | ||
private const string VariableRegexPattern = @"\b[A-Za-z]\w*\b"; | ||
|
||
public VariableDomainGrammarIrony() | ||
: base(caseSensitive: false) | ||
{ | ||
LanguageFlags = LanguageFlags.CreateAst | | ||
LanguageFlags.NewLineBeforeEOF; | ||
|
||
var RANGE = ToTerm("..", "range"); | ||
var FUNCTION_CALL_ARGUMENT_SEPERATOR = ToTerm(","); | ||
var OPEN_ARG = ToTerm("("); | ||
var CLOSE_ARG = ToTerm(")"); | ||
|
||
// Terminals | ||
var numberLiteral = new NumberLiteral("number literal", NumberOptions.IntOnly, typeof (NumberLiteralNode)); | ||
var functionCallArgumentStringLiteral = new RegexBasedTerminal("function call argument string literal", FunctionArgumentStringLiteralPattern); | ||
functionCallArgumentStringLiteral.AstConfig.NodeType = typeof (FunctionCallArgumentStringLiteralNode); | ||
var functionName = new RegexBasedTerminal("function name", FunctionNamePattern); | ||
functionName.AstConfig.NodeType = typeof (FunctionNameNode); | ||
var domainName = new RegexBasedTerminal("domain name", VariableRegexPattern); | ||
domainName.AstConfig.NodeType = typeof(DomainNameNode); | ||
|
||
// Non-terminals | ||
var domainExpression = new NonTerminal("domainExpression", typeof (DomainExpressionNode)); | ||
var bandExpression = new NonTerminal("expression", typeof (BandExpressionNode)); | ||
var functionCall = new NonTerminal("function call", typeof (FunctionCallXNode)); | ||
var functionCallArgumentList = new NonTerminal("function call arguments", typeof (FunctionArgumentListNode)); | ||
var functionCallArgument = new NonTerminal("function argument", typeof (FunctionCallArgumentNode)); | ||
var sharedDomainReference = new NonTerminal("shared domain reference", typeof(SharedDomainReferenceNode)); | ||
var variableDomainExpression = new NonTerminal("variable domain expression", typeof(VariableDomainExpressionNode)); | ||
|
||
// BNF rules | ||
functionCallArgument.Rule = numberLiteral | functionCallArgumentStringLiteral; | ||
functionCall.Rule = functionName + OPEN_ARG + functionCallArgumentList + CLOSE_ARG; | ||
functionCallArgumentList.Rule = MakePlusRule(functionCallArgumentList, FUNCTION_CALL_ARGUMENT_SEPERATOR, functionCallArgument); | ||
bandExpression.Rule = numberLiteral | functionCall; | ||
domainExpression.Rule = bandExpression + RANGE + bandExpression; | ||
sharedDomainReference.Rule = domainName; | ||
variableDomainExpression.Rule = domainExpression | sharedDomainReference; | ||
|
||
Root = variableDomainExpression; | ||
|
||
MarkPunctuation(RANGE, FUNCTION_CALL_ARGUMENT_SEPERATOR); | ||
MarkPunctuation(OPEN_ARG, CLOSE_ARG); | ||
|
||
RegisterBracePair("(", ")"); | ||
} | ||
} | ||
} |
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.