Code Monkey home page Code Monkey logo

facio's People

Contributors

danielfabian avatar jack-pappas avatar reedcopsey avatar sergey-tihon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

facio's Issues

Migrate logging to Microsoft.Extensions.Logging

At present, the facio projects all have a hard dependency on NLog for logging. This is generally fine for the executables (e.g., fsharplex) but is an annoyance for anyone who wants to use the libraries (e.g. Reggie, Graham) within some other projects.

Now that .NET 4.7.1 is available with .NET Standard 2.0 support, let's migrate the projects up to targeting some version(s) of netstandard and netcoreapp. Once that's done, we can switch the logging implementation over to using the relatively-new Microsoft.Extensions.Logging packages. This'll allow the library projects to use only the logging abstractions (interfaces) from the interface package, perhaps falling back to a TraceSource-based provider if an instance isn't injected by the calling application. Applications utilizing the libraries (incl. other facio projects) can specify which logger implementation to use, e.g. via their app.config.

fsharplex does not emit position information

fsharplex does not yet emit position information (i.e., line numbers) from the specification file into the generated lexer code, so if your lexer encounters an error -- for example, a bug or syntax error in one of the user-defined lexical actions -- it may be difficult to trace the position specified by the compiler error or exception stack trace back to the original code in the specification file.

Order of --unicode matters

When passing --unicode right after the command line to FSharpLex, no error is given but the generated file uses the AsciiTables.

Multi-way conflicts cause Graham to crash

Graham is currently unable to handle multi-way conflicts at all -- they cause the library to crash when attempting to compile an LR(0) (incl. SLR(1), LALR(1)) table.

In the short-term, this could be fixed by using the same conflict-resolution algorithm fsyacc uses. It causes issues of it's own, but it'll keep the library from crashing and may be useful for getting fsharpyacc to parity with fsyacc.

For the long-term, we'll need to implement a robust algorithm for multi-way conflict resolution.

Implement unit tests for the CharSet type in fsharplex

Implement some basic tests for the CharSet type in fsharplex. It would be enough to use FsCheck to implement some round-trip tests (Set<char> -> CharSet -> Set<char> and CharSet -> Set<char> -> CharSet) and some 1-to-1 comparisons with Set<char> for various operations like fold.

Option to run tools in precompile / validation-only mode

It would be a useful feature if fsharplex and fsharpyacc supported an option not to invoke any backend at all; in this mode, the lexer / parser specification would be compiled as usual, but the code-generation phase at the end would be skipped.

This would be used when running in an IDE to provide warning/error messages to the user. In the current version of fsharplex, the code-generation phase for the fslex-compatible backend accounts for over half of the tool's running time; skipping that phase would make it possible to provide almost-instant feedback to the user.

Problem building from build.bat

Pulled latest from yesterday.

Solution builds fine inside VS2015, but building from build.bat/build.fsx is problematic.

First problem:

"D:\BitSync\GitRepos\facio\facio.sln" (Build target) (1) ->
"D:\BitSync\GitRepos\facio\Reggie\Reggie.fsproj" (default target) (12) ->
(CoreCompile target) ->
D:\BitSync\GitRepos\facio\Reggie\Regex.fs(329,11): error FS1171: Expected single line comment or end of line [D:\BitSync\GitRepos\facio\Reggie\Reggie.fsproj]

...ended up not so trivial to fix, I finally commented out the block of code

if DEBUG && TRACE

    // For testing purposes, it's sometimes useful to print out the simplification steps.
    // Don't call Regex.PrintFSharpCode unless the output is actually going to be used,
    // as it's relatively expensive in terms of performance.
    if regexSimplifyTrace.Switch.ShouldTrace TraceEventType.Verbose then
        regexSimplifyTrace.TraceInformation (Regex.PrintFSharpCode regex)

endif

...and moved on to the following error (although it still built within VS2015)

"D:\BitSync\GitRepos\facio\facio.sln" (Build target) (1) ->
"D:\BitSync\GitRepos\facio\Reggie.Tests\Reggie.Tests.fsproj" (default target) (11) ->
(CoreCompile target) ->
D:\BitSync\GitRepos\facio\Reggie.Tests\Collections.fs(407,13): error FS0039: The value, namespace, type or module 'TupleUtils' is not defined [D:\BitSync\GitRepos\facio\Reggie.Tests\Reggie.Tests.fsproj]
D:\BitSync\GitRepos\facio\Reggie.Tests\Collections.fs(425,13): error FS0039: The value, namespace, type or module 'TupleUtils' is not defined [D:\BitSync\GitRepos\facio\Reggie.Tests\Reggie.Tests.fsproj]

...possibly related: several projects including Reggie show a blank Target F# runtime in the project properties window.

Improve performance of fsharpyacc / Graham

Some parts of the LR (LR(0), SLR(1), LALR(1), LR(1)) parser table generation have not been optimized yet. This issue doesn't impact smaller parser specifications, but larger specifications such as the parser for the F# compiler can take a long time to compile. The parts of the code causing the performance drain will eventually be profiled and tuned to correct the problem; the likely solution will be to implement memoization in some places, and to increase the performance of some Map lookups by using TagBimap to assign 'tags' which can be used in place of more heavyweight objects (e.g., LrParserState<_,_,_>).

Implement benchmarks

It would be good to have some benchmarks for fsharplex/fsharpyacc to quantify their performance; this would be particularly useful when implementing performance improvements, so we can see the performance before and after the improvements (to make sure they're really improvements!)

The benchmarks will need to cover both the run-times of fsharplex/fsharpyacc themselves (i.e., how long they take to compile a specification) and the run-times of the generated F# code (by running the generated lexers/parsers against some input file(s)).

FsCheck tests for Regex in Reggie.Tests crash

In Reggie.Tests, the FsCheck-based tests for the Regex type crash. However, the FsCheck-based tests for the CharSet type do run correctly. Registration of the generators for both types are done at the same time, in the same way -- so it's unclear why the Regex tests are crashing.

The error message for all of the tests in the RegexRandomizedTests module is:

System.Exception : Geneflect: type not handled System.Collections.Generic.IEnumerable`1[System.Char]
   at [email protected](String message)
   at FsCheck.Common.f@1[a,b](IDictionary`2 memo, FSharpFunc`2 f, a n, Unit _arg1)
   at FsCheck.Common.memoizeWith(IDictionary`2 memo, FSharpFunc`2 f, a n)
   at FsCheck.ReflectArbitrary.reflectGen(FSharpFunc`2 getGenerator)
   at <StartupCode$Reggie-Tests>[email protected](Unit unitVar) in TestSetup.fs: line 42
   at [email protected](Int32 n, StdGen r)
   at <StartupCode$FsCheck>[email protected](Int32 n, StdGen r)
   at FsCheck.Gen.go@193[b](FSharpList`1 gs, FSharpList`1 acc, Int32 size, StdGen r0)
   at [email protected](Int32 n, StdGen r)
   at <StartupCode$FsCheck>[email protected](Int32 n, StdGen r)
   at <StartupCode$FsCheck>[email protected](Int32 n, StdGen r)
   at <StartupCode$FsCheck>[email protected](Int32 n, StdGen r)
   at [email protected](Int32 n, StdGen r0)
   at [email protected](ref IEnumerable`1 next)
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.MoveNextImpl()
   at Microsoft.FSharp.Collections.SeqModule.TakeWhile@1490.GenerateNext(ref IEnumerable`1 next)
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.MoveNextImpl()
   at Microsoft.FSharp.Collections.SeqModule.Fold(FSharpFunc`2 folder, TState state, IEnumerable`1 source)
   at FsCheck.Runner.runner(Config config, a prop)
   at FsCheck.Runner.check(Config config, a p)
   at TestHelpers.assertProp(String testName, Testable property) in TestHelpers.fs: line 119
   at Tests.Reggie.RegexRandomizedTests.a language AND-ed with itself then simplified returns the original language() in Regex.fs: line 75

Add functionality to test harness to tokenize sample input files and compare against reference results

The test harnesses for fsharplex and fsharpyacc currently run their respective tools against the lexer/parser specifications included in the TestCases folder of this repository. This is useful for quickly checking that fsharplex and fsharpyacc are able to compile a variety of real-world input specifications, and the generated code can be manually inspected to determine if it looks roughly correct (i.e., there are no obvious errors).

However, this manual checking is time-consuming and it certainly isn't robust. The only means I currently have of checking whether the generated code works correctly is to compile an input specification from an application whose source code is available, copy the generated code into the application, compile the application, and run it. If the program crashes, I assume the generated code is bad; if it doesn't, I assume the generated code is good. Either way leaves open the possibility of false positives or negatives.

It would be exceedingly useful to extend the existing functionality of the test harnesses so that for some subset of the TestCases, the generated code could be compiled into a "skeleton" application which would run against some example input files, tokenize/parse them, dump the results to a file, and compare them against some known-good results generated with fslex/fsyacc. This would make it easy and fast to check that:

  1. the generated code doesn't contain obvious syntactical errors that cause it to be rejected by the F# compiler;
  2. the automata is correctly encoded by the backend (this is really tricky to debug when it occurs!);
  3. the automata is approximately correct -- it correctly tokenizes/parses the input file and produces the same output as the reference result.

It seems like this would be easiest to implement this for fsharplex first; unless one or more of the tokens defined by a lexer specification (*.fsl) carry a value of some type defined in another part of a the original program's code, the skeleton application can be very simple -- it'll only consist of the generated lexer and a simple console app which reads an input file, runs it against the lexer to produce tokens until the input is exhausted, then writes the tokens to an output file.

solution does not build out of the box in VS2015

Looks like the test projects reference conflicting versions of FsCheck, in fixing this I opted to upgrade to FsCheck 2.2.4 and found somewhere between patch releases 2.2.2 and 2.2.4 there is a breaking change in the constructor to TestResult.True which has to be fixed in TestHelpers.fs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.