Skip to content

Commit

Permalink
fixed bug with standalone lexer documents not being able to be genera…
Browse files Browse the repository at this point in the history
…ted to code
codewitch-honey-crisis committed Nov 24, 2019
1 parent ef337f5 commit d923245
Showing 5 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions common/GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -14,5 +14,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("0.0.1.12")]
[assembly: AssemblyFileVersion("0.0.1.12")]
[assembly: AssemblyVersion("0.0.1.13")]
[assembly: AssemblyFileVersion("0.0.1.13")]
Binary file added pck.refresh.v0.0.1.12.zip
Binary file not shown.
10 changes: 10 additions & 0 deletions pckw/TokenizerCodeGenerator.cs
Original file line number Diff line number Diff line change
@@ -98,6 +98,16 @@ public static void WriteClassTo(LexDocument lex, IList<string> symbolTable, stri
if (string.IsNullOrEmpty(language))
language = "cs";
var cdp = CodeDomProvider.CreateProvider(language);
if(2==symbolTable.Count && "#EOS"== symbolTable[0] && "#ERROR"==symbolTable[1])
{
// this is a lex document and the cfg was a dummy so we don't use it.
// build the symbol table from the LexDocument
symbolTable = new List<string>();
foreach(var rule in lex.Rules)
symbolTable.Add(rule.Left);
symbolTable.Add("#EOS");
symbolTable.Add("#ERROR");
}
var tokenizer = _CreateTokenizerClass(lex, symbolTable, name,progress);
var opts = new CodeGeneratorOptions();
opts.BlankLinesBetweenMembers = false;
5 changes: 2 additions & 3 deletions scratch/xbnf.xbnf
Original file line number Diff line number Diff line change
@@ -61,11 +61,10 @@ lineComment<hidden>= '//[^\n]*[\n]';
blockComment<hidden,blockEnd="*/">= "/*";

// defining these isn't required, but gives
// us better constant names and an opportunity to
// remove them from the tree.
// us better constant names
//
// double quotes denote a literal. the escapes are nearly the
// same as C#. \U and \x are not supported
// same as C#. \U and \x are not supported but \u is
or="|";
lt="<";
gt=">";
8 changes: 5 additions & 3 deletions xbnf/XbnfDocument.cs
Original file line number Diff line number Diff line change
@@ -83,9 +83,11 @@ public IList<XbnfMessage> TryValidate(IList<XbnfMessage> result = null)
o = prod.Attributes[i].Value;
isHidden = (o is bool && (bool)o);
}
if (!isHidden && !Equals(rc.Key, StartProduction.Name))
result.Add(new XbnfMessage(ErrorLevel.Warning, -1, string.Concat("Unreferenced production \"", prod.Name, "\""),
prod.Line, prod.Column, prod.Position, Filename));
var sp = StartProduction;
if(null!=sp)
if (!isHidden && !Equals(rc.Key, sp.Name))
result.Add(new XbnfMessage(ErrorLevel.Warning, -1, string.Concat("Unreferenced production \"", prod.Name, "\""),
prod.Line, prod.Column, prod.Position, Filename));
}
}
return result;

0 comments on commit d923245

Please sign in to comment.