From 880f2b81543d40440d169ab289cd6e87c01c6c67 Mon Sep 17 00:00:00 2001 From: Peter Forstmeier Date: Sun, 29 Sep 2013 19:55:42 +0200 Subject: [PATCH] Derive Grammer --- .../ICSharpCode.Reporting.csproj | 3 ++ .../Irony/ReportingLanguageGrammer.cs | 25 ++++++++++++++++ .../Irony/ReportingLanguageRuntime.cs | 29 +++++++++++++++++++ .../src/Expressions/IronyGeneral.cs | 3 +- 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageGrammer.cs create mode 100644 src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageRuntime.cs diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj index a6feaaf15d..42fa9c1967 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj @@ -109,6 +109,8 @@ + + @@ -154,6 +156,7 @@ + diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageGrammer.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageGrammer.cs new file mode 100644 index 0000000000..8cb1e5a0ca --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageGrammer.cs @@ -0,0 +1,25 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) +using System; +using Irony; +using Irony.Interpreter; +using Irony.Interpreter.Evaluator; +using Irony.Parsing; + +namespace ICSharpCode.Reporting.Expressions.Irony +{ + /// + /// Description of ReportingLanguageGrammer. + /// + public class ReportingLanguageGrammer:ExpressionEvaluatorGrammar + { + public ReportingLanguageGrammer() + { + } + + public override LanguageRuntime CreateRuntime(LanguageData language) + { + return new ReportingLanguageRuntime(language); + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageRuntime.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageRuntime.cs new file mode 100644 index 0000000000..7f61faffc4 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageRuntime.cs @@ -0,0 +1,29 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) +using System; +using Irony.Interpreter; +using Irony.Parsing; + +namespace ICSharpCode.Reporting.Expressions.Irony +{ + /// + /// Description of ReportingLanguageRuntime. + /// + public class ReportingLanguageRuntime:LanguageRuntime + { + public ReportingLanguageRuntime(LanguageData language):base(language) + { + } + + public override void Init() + { + base.Init(); + //add built-in methods, special form IIF, import Math and Environment methods + // BuiltIns.AddMethod(BuiltInPrintMethod, "print"); + // BuiltIns.AddMethod(BuiltInFormatMethod, "format"); + BuiltIns.AddSpecialForm(SpecialFormsLibrary.Iif, "iif", 3, 3); + BuiltIns.ImportStaticMembers(typeof(System.Math)); + BuiltIns.ImportStaticMembers(typeof(Environment)); + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IronyGeneral.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IronyGeneral.cs index 9c98ae5568..8d45d125b3 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IronyGeneral.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IronyGeneral.cs @@ -1,6 +1,7 @@ // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using ICSharpCode.Reporting.Expressions.Irony; using Irony.Interpreter.Evaluator; using NUnit.Framework; @@ -63,7 +64,7 @@ namespace ICSharpCode.Reporting.Test.Expressions [SetUp] public void Initialize() { - grammar = new ExpressionEvaluatorGrammar(); + grammar = new ReportingLanguageGrammer(); evaluator = new ExpressionEvaluator(grammar); } }