diff --git a/AbnfToAntlr.Common/AbnfToAntlr.Common.csproj b/AbnfToAntlr.Common/AbnfToAntlr.Common.csproj index a7ae86a..34acbf6 100644 --- a/AbnfToAntlr.Common/AbnfToAntlr.Common.csproj +++ b/AbnfToAntlr.Common/AbnfToAntlr.Common.csproj @@ -47,13 +47,16 @@ + + + -<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AbnfToAntlr.Web.Default" %> +<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="Default.aspx.cs" Inherits="AbnfToAntlr.Web.DefaultPage" %> ABNF to ANTLR
-

- ABNF To ANTLR

-

- Translate any ABNF grammar to an ANTLR grammar. The resulting ANTLR grammar should be syntactically correct; however, some ABNF grammars are inherently ambiguous and ANTLR will complain about them until the ambiguity is resolved by the user. The translator uses parser and lexer components generated by the excellent ANTLR toolset. Source code and binaries are available on - GitHub. -

- -
- -
-
- -      - ABNF To ANTLR +

+ Translate any ABNF grammar to an ANTLR grammar. The resulting ANTLR grammar should be syntactically correct; however, some ABNF grammars are inherently ambiguous and ANTLR will complain about them until the ambiguity is resolved by the user. The translator uses parser and lexer components generated by the excellent ANTLR toolset. Source code and binaries are available on + GitHub +

+ +
+ +
+
+ +      + -
-
- -
- -
- +
+
+ +
+ +
+ diff --git a/AbnfToAntlr.Web/Default.aspx.cs b/AbnfToAntlr.Web/Default.aspx.cs index 3aa75fa..b70265a 100644 --- a/AbnfToAntlr.Web/Default.aspx.cs +++ b/AbnfToAntlr.Web/Default.aspx.cs @@ -84,7 +84,7 @@ Official character names from Unicode.org namespace AbnfToAntlr.Web { - public partial class Default : System.Web.UI.Page + public partial class DefaultPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { @@ -134,5 +134,6 @@ protected void Page_Load(object sender, EventArgs e) this.txtError.Visible = false; } } + } } \ No newline at end of file diff --git a/AbnfToAntlr.Web/Default.aspx.designer.cs b/AbnfToAntlr.Web/Default.aspx.designer.cs index 85dfb06..7e8cc81 100644 --- a/AbnfToAntlr.Web/Default.aspx.designer.cs +++ b/AbnfToAntlr.Web/Default.aspx.designer.cs @@ -10,7 +10,7 @@ namespace AbnfToAntlr.Web { - public partial class Default { + public partial class DefaultPage { /// /// form1 control. diff --git a/AbnfToAntlr.Web/Properties/AssemblyInfo.cs b/AbnfToAntlr.Web/Properties/AssemblyInfo.cs index c056f80..0739ac0 100644 --- a/AbnfToAntlr.Web/Properties/AssemblyInfo.cs +++ b/AbnfToAntlr.Web/Properties/AssemblyInfo.cs @@ -52,5 +52,5 @@ You should have received a copy of the GNU General Public License // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.2.0.0")] -[assembly: AssemblyFileVersion("1.2.0.0")] +[assembly: AssemblyVersion("1.3.0.0")] +[assembly: AssemblyFileVersion("1.3.0.0")] diff --git a/AbnfToAntlr/Program.cs b/AbnfToAntlr/Program.cs index 7547c19..6af8762 100644 --- a/AbnfToAntlr/Program.cs +++ b/AbnfToAntlr/Program.cs @@ -36,7 +36,7 @@ static void ShowSyntax() Console.Error.WriteLine("Translate FILE to ANTLR format and write the results to standard output."); Console.Error.WriteLine("If --stdin is specified instead of FILE, then standard input is used."); Console.Error.WriteLine("If --direct is specified, then a direct translation is performed."); - Console.Error.WriteLine("Example: AbnfToAntlr \"AbnfGrammar.txt\" >AntlrGrammar.g"); + Console.Error.WriteLine("Example: AbnfToAntlr \"AbnfGrammar.txt\" >\"AntlrGrammar.g4\""); } [STAThread] @@ -47,9 +47,7 @@ static int Main(string[] args) { if (args.Length == 0) { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new frmMain()); + WinFormsMain(); return 0; } else @@ -58,11 +56,18 @@ static int Main(string[] args) } } + static void WinFormsMain() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new frmMain()); + } + static int ConsoleMain(string[] args) { bool shouldShowSyntax = false; bool shouldPerformDirectTranslation = false; - int fileIndex = 0; + int fileArgIndex = 0; if (args.Length == 0) { @@ -84,18 +89,17 @@ static int ConsoleMain(string[] args) case "--direct": shouldPerformDirectTranslation = true; - fileIndex = 1; + fileArgIndex = 1; break; } } - if (shouldShowSyntax || fileIndex >= args.Length || args.Length > fileIndex + 1) + if (shouldShowSyntax || fileArgIndex >= args.Length || args.Length > fileArgIndex + 1) { ShowSyntax(); return 1; } - string path = null; System.IO.TextReader reader; string input; @@ -104,7 +108,7 @@ static int ConsoleMain(string[] args) try { // open input stream - if (args[fileIndex] == "--stdin") + if (args[fileArgIndex] == "--stdin") { path = "stdin"; reader = System.Console.In; diff --git a/AbnfToAntlr/Properties/AssemblyInfo.cs b/AbnfToAntlr/Properties/AssemblyInfo.cs index 4eac882..abacc9f 100644 --- a/AbnfToAntlr/Properties/AssemblyInfo.cs +++ b/AbnfToAntlr/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.0.0")] -[assembly: AssemblyFileVersion("1.2.0.0")] +[assembly: AssemblyVersion("1.3.0.0")] +[assembly: AssemblyFileVersion("1.3.0.0")] diff --git a/AbnfToAntlr/frmMain.Designer.cs b/AbnfToAntlr/frmMain.Designer.cs index f07ff34..8fa248c 100644 --- a/AbnfToAntlr/frmMain.Designer.cs +++ b/AbnfToAntlr/frmMain.Designer.cs @@ -31,10 +31,11 @@ private void InitializeComponent() this.txtInput = new System.Windows.Forms.TextBox(); this.txtOutput = new System.Windows.Forms.TextBox(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.btnTranslate = new System.Windows.Forms.Button(); - this.chkPerformDirectTranslation = new System.Windows.Forms.CheckBox(); this.lblInput = new System.Windows.Forms.Label(); + this.chkPerformDirectTranslation = new System.Windows.Forms.CheckBox(); + this.btnTranslate = new System.Windows.Forms.Button(); this.lblOutput = new System.Windows.Forms.Label(); + this.btnClose = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); @@ -50,7 +51,7 @@ private void InitializeComponent() this.txtInput.Multiline = true; this.txtInput.Name = "txtInput"; this.txtInput.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.txtInput.Size = new System.Drawing.Size(454, 125); + this.txtInput.Size = new System.Drawing.Size(454, 109); this.txtInput.TabIndex = 0; // // txtOutput @@ -63,7 +64,7 @@ private void InitializeComponent() this.txtOutput.Name = "txtOutput"; this.txtOutput.ReadOnly = true; this.txtOutput.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.txtOutput.Size = new System.Drawing.Size(454, 130); + this.txtOutput.Size = new System.Drawing.Size(454, 117); this.txtOutput.TabIndex = 1; // // splitContainer1 @@ -86,26 +87,24 @@ private void InitializeComponent() // this.splitContainer1.Panel2.Controls.Add(this.lblOutput); this.splitContainer1.Panel2.Controls.Add(this.txtOutput); - this.splitContainer1.Size = new System.Drawing.Size(460, 338); - this.splitContainer1.SplitterDistance = 179; + this.splitContainer1.Size = new System.Drawing.Size(460, 309); + this.splitContainer1.SplitterDistance = 163; this.splitContainer1.TabIndex = 2; // - // btnTranslate + // lblInput // - this.btnTranslate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnTranslate.Location = new System.Drawing.Point(3, 153); - this.btnTranslate.Name = "btnTranslate"; - this.btnTranslate.Size = new System.Drawing.Size(75, 23); - this.btnTranslate.TabIndex = 1; - this.btnTranslate.Text = "Translate"; - this.btnTranslate.UseVisualStyleBackColor = true; - this.btnTranslate.Click += new System.EventHandler(this.btnTranslate_Click); + this.lblInput.AutoSize = true; + this.lblInput.Location = new System.Drawing.Point(6, 6); + this.lblInput.Name = "lblInput"; + this.lblInput.Size = new System.Drawing.Size(83, 13); + this.lblInput.TabIndex = 3; + this.lblInput.Text = "ABNF Grammar:"; // // chkPerformDirectTranslation // this.chkPerformDirectTranslation.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.chkPerformDirectTranslation.AutoSize = true; - this.chkPerformDirectTranslation.Location = new System.Drawing.Point(84, 157); + this.chkPerformDirectTranslation.Location = new System.Drawing.Point(84, 141); this.chkPerformDirectTranslation.Name = "chkPerformDirectTranslation"; this.chkPerformDirectTranslation.Size = new System.Drawing.Size(374, 17); this.chkPerformDirectTranslation.TabIndex = 2; @@ -113,14 +112,16 @@ private void InitializeComponent() ""; this.chkPerformDirectTranslation.UseVisualStyleBackColor = true; // - // lblInput + // btnTranslate // - this.lblInput.AutoSize = true; - this.lblInput.Location = new System.Drawing.Point(6, 6); - this.lblInput.Name = "lblInput"; - this.lblInput.Size = new System.Drawing.Size(83, 13); - this.lblInput.TabIndex = 3; - this.lblInput.Text = "ABNF Grammar:"; + this.btnTranslate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnTranslate.Location = new System.Drawing.Point(3, 137); + this.btnTranslate.Name = "btnTranslate"; + this.btnTranslate.Size = new System.Drawing.Size(75, 23); + this.btnTranslate.TabIndex = 1; + this.btnTranslate.Text = "Translate"; + this.btnTranslate.UseVisualStyleBackColor = true; + this.btnTranslate.Click += new System.EventHandler(this.btnTranslate_Click); // // lblOutput // @@ -131,11 +132,25 @@ private void InitializeComponent() this.lblOutput.TabIndex = 4; this.lblOutput.Text = "ANTLR Grammar:"; // + // btnClose + // + this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnClose.Location = new System.Drawing.Point(397, 327); + this.btnClose.Name = "btnClose"; + this.btnClose.Size = new System.Drawing.Size(75, 23); + this.btnClose.TabIndex = 4; + this.btnClose.Text = "Close"; + this.btnClose.UseVisualStyleBackColor = true; + this.btnClose.Click += new System.EventHandler(this.btnClose_Click); + // // frmMain // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.btnClose; this.ClientSize = new System.Drawing.Size(484, 362); + this.Controls.Add(this.btnClose); this.Controls.Add(this.splitContainer1); this.MinimumSize = new System.Drawing.Size(500, 200); this.Name = "frmMain"; @@ -159,6 +174,7 @@ private void InitializeComponent() private System.Windows.Forms.Button btnTranslate; private System.Windows.Forms.Label lblInput; private System.Windows.Forms.Label lblOutput; + private System.Windows.Forms.Button btnClose; } } diff --git a/AbnfToAntlr/frmMain.cs b/AbnfToAntlr/frmMain.cs index 07fbcb3..7599a23 100644 --- a/AbnfToAntlr/frmMain.cs +++ b/AbnfToAntlr/frmMain.cs @@ -75,5 +75,10 @@ private void btnTranslate_Click(object sender, EventArgs e) btnTranslate.Enabled = true; } } + + private void btnClose_Click(object sender, EventArgs e) + { + this.Close(); + } } }