]> git.wincent.com - docvim.git/log
docvim.git
6 years agoMake unit tests a little more real
Greg Hurrell [Tue, 22 Mar 2016 15:58:06 +0000 (08:58 -0700)] 
Make unit tests a little more real

Before going much further though I want to set up tasty-golden, so I can
take an input file, parse it, and compare the pretty-printed output.

Will need pretty printing before I do that though...

6 years agoParse `let x=1`
Greg Hurrell [Tue, 22 Mar 2016 15:28:04 +0000 (08:28 -0700)] 
Parse `let x=1`

Still doesn't come close to handling all the variants listed in `:help
:let`, but it's a start.

6 years agoAdd crude support for :let
Greg Hurrell [Tue, 22 Mar 2016 15:04:16 +0000 (08:04 -0700)] 
Add crude support for :let

Parses:

  let foo = 1

Doesn't yet parse:

  let foo=1

(Or a bunch of other forms mentioned under `:h :let`.)

6 years agoKill off some commented out code
Greg Hurrell [Tue, 22 Mar 2016 14:45:37 +0000 (07:45 -0700)] 
Kill off some commented out code

6 years agoHandle multiple lines of whitespace in a few places
Greg Hurrell [Tue, 22 Mar 2016 14:44:54 +0000 (07:44 -0700)] 
Handle multiple lines of whitespace in a few places

6 years agoLet EOF terminate statements as well
Greg Hurrell [Tue, 22 Mar 2016 14:37:16 +0000 (07:37 -0700)] 
Let EOF terminate statements as well

6 years agoMake docBlockStart error messages more readable
Greg Hurrell [Tue, 22 Mar 2016 14:36:52 +0000 (07:36 -0700)] 
Make docBlockStart error messages more readable

6 years agoRequire end-of-statement after :endf
Greg Hurrell [Tue, 22 Mar 2016 14:31:12 +0000 (07:31 -0700)] 
Require end-of-statement after :endf

Allows us to parse a trailing "endf\n".

Note that `:h :endf` says `:endf` must be on a line all by itself, but
this is not technically true. Vim will happily accept this:

  endf | echomsg "Hi!"

Even if it doesn't actually run the `:echomsg` call... It does, however,
complain with:

  E126: Missing :endfunction

if you try to give it something like:

  echo 1 | endf

I'm currently not handling that case, I think.

6 years agoAdd end-of-statement combinator
Greg Hurrell [Tue, 22 Mar 2016 14:21:52 +0000 (07:21 -0700)] 
Add end-of-statement combinator

Fixes the issue described in b52afe67bd403ef401c972c859093bbe.

6 years agoAdd initial support for parsing function bodies
Greg Hurrell [Tue, 22 Mar 2016 14:06:43 +0000 (07:06 -0700)] 
Add initial support for parsing function bodies

Some whitespace issues still to deal with. This won't parse:

  fu X()
  unlet g:thing
  endf

But this will:

  fu X()
  unlet g:thing endf

6 years agoFix lints
Greg Hurrell [Tue, 22 Mar 2016 13:59:10 +0000 (06:59 -0700)] 
Fix lints

6 years agoFix whitespace
Greg Hurrell [Tue, 22 Mar 2016 13:57:05 +0000 (06:57 -0700)] 
Fix whitespace

6 years agoParse :unlet
Greg Hurrell [Tue, 22 Mar 2016 13:55:39 +0000 (06:55 -0700)] 
Parse :unlet

6 years agoFlatten data types hierarchy more
Greg Hurrell [Tue, 22 Mar 2016 06:09:41 +0000 (23:09 -0700)] 
Flatten data types hierarchy more

6 years agoMove top-level whitespace skipping to unit combinator
Greg Hurrell [Tue, 22 Mar 2016 05:51:28 +0000 (22:51 -0700)] 
Move top-level whitespace skipping to unit combinator

6 years agoShow function attributes when pretty-printing FunctionDeclaration AST
Greg Hurrell [Tue, 22 Mar 2016 05:33:07 +0000 (22:33 -0700)] 
Show function attributes when pretty-printing FunctionDeclaration AST

6 years agoStart folding more things into Node data type
Greg Hurrell [Tue, 22 Mar 2016 03:43:48 +0000 (20:43 -0700)] 
Start folding more things into Node data type

6 years agoStart rejigging AST data types to make them flatter
Greg Hurrell [Tue, 22 Mar 2016 01:49:02 +0000 (18:49 -0700)] 
Start rejigging AST data types to make them flatter

The pseudo-inheritance thing is just not going to work out.

6 years agoHandle line continuation markers
Greg Hurrell [Tue, 22 Mar 2016 00:59:35 +0000 (17:59 -0700)] 
Handle line continuation markers

Probably horrible performance-wise, due to the `try` lookahead.

6 years agoUse terser syntax for newline combinator
Greg Hurrell [Tue, 22 Mar 2016 00:44:08 +0000 (17:44 -0700)] 
Use terser syntax for newline combinator

6 years agoParse function "attributes"
Greg Hurrell [Mon, 21 Mar 2016 15:56:40 +0000 (08:56 -0700)] 
Parse function "attributes"

`abort`, `range`, and `dict`.

Like Vim, we allow repetition, although it is kind of non-sensical, and
we also require the `:function` command to be on a line by itself.

Note the use of `sepEndBy` rather than `sepBy`, otherwise any trailing
whitespace will be taken to indicate that another attribute follows,
even though only a newline may follow.

6 years agoUse record syntax for FunctionDeclaration
Greg Hurrell [Mon, 21 Mar 2016 14:37:01 +0000 (07:37 -0700)] 
Use record syntax for FunctionDeclaration

Only at the `data` type declaration, not at the usage sites (yet).
Primarily do make it self-documenting, but as I add more options it will
become useful to use record accessors at usage sites as well.

6 years agoImprove a code comment
Greg Hurrell [Mon, 21 Mar 2016 14:31:06 +0000 (07:31 -0700)] 
Improve a code comment

6 years agoMake `command` function more readable at callsites
Greg Hurrell [Mon, 21 Mar 2016 14:27:39 +0000 (07:27 -0700)] 
Make `command` function more readable at callsites

At the cost of some internal complexity.

6 years agoIndicate declaration vs redeclaration with a Bool
Greg Hurrell [Mon, 21 Mar 2016 14:10:12 +0000 (07:10 -0700)] 
Indicate declaration vs redeclaration with a Bool

At the same time, switched from monadic to applicative style. I expect
I'll need to switch back to monadic before this is all over, but for
now, this is a simplification.

6 years agoFix a couple of whitespace-handling errors
Greg Hurrell [Mon, 21 Mar 2016 07:21:22 +0000 (00:21 -0700)] 
Fix a couple of whitespace-handling errors

6 years agoFix lints
Greg Hurrell [Mon, 21 Mar 2016 07:15:55 +0000 (00:15 -0700)] 
Fix lints

6 years agoPretty print arg lists
Greg Hurrell [Mon, 21 Mar 2016 07:08:18 +0000 (00:08 -0700)] 
Pretty print arg lists

6 years agoParse function arguments
Greg Hurrell [Mon, 21 Mar 2016 06:45:08 +0000 (23:45 -0700)] 
Parse function arguments

6 years agoDRY up function declaration constructors
Greg Hurrell [Mon, 21 Mar 2016 06:36:34 +0000 (23:36 -0700)] 
DRY up function declaration constructors

6 years agoTidy
Greg Hurrell [Mon, 21 Mar 2016 06:27:00 +0000 (23:27 -0700)] 
Tidy

6 years agoVariable function names
Greg Hurrell [Mon, 21 Mar 2016 06:18:10 +0000 (23:18 -0700)] 
Variable function names

6 years agoExpect function name
Greg Hurrell [Mon, 21 Mar 2016 06:16:12 +0000 (23:16 -0700)] 
Expect function name

Hardcoded "name" for now just to show that this can work.

6 years agoAdd preliminary support for :endfunction
Greg Hurrell [Mon, 21 Mar 2016 05:49:58 +0000 (22:49 -0700)] 
Add preliminary support for :endfunction

6 years agoProvide example custom show instance
Greg Hurrell [Sun, 20 Mar 2016 14:36:29 +0000 (07:36 -0700)] 
Provide example custom show instance

Prints "[VimL function]"/"[VimL function!]" instead of "[VimL
FunctionDeclaration]"/"[VimL FunctionRedeclaration]".

Not sure whether this is a pattern I want to follow, but I wanted an
example of it anyway.

6 years agoBetter error messages for `command` failure
Greg Hurrell [Sun, 20 Mar 2016 14:22:06 +0000 (07:22 -0700)] 
Better error messages for `command` failure

6 years agoFix precedence bug in command
Greg Hurrell [Sun, 20 Mar 2016 08:56:47 +0000 (01:56 -0700)] 
Fix precedence bug in command

Was matching "funcion" (note the missing "t").

6 years agoMake command helper
Greg Hurrell [Sun, 20 Mar 2016 08:48:34 +0000 (01:48 -0700)] 
Make command helper

6 years agoReturn FunctionDeclaration or FunctionRedeclaration conditionally
Greg Hurrell [Sun, 20 Mar 2016 08:17:26 +0000 (01:17 -0700)] 
Return FunctionDeclaration or FunctionRedeclaration conditionally

Based on absence/presence of trailing exclamation point.

6 years agoShow alternate means of matching fu, fun, func etc
Greg Hurrell [Sun, 20 Mar 2016 08:08:09 +0000 (01:08 -0700)] 
Show alternate means of matching fu, fun, func etc

6 years agoMake FunctionDeclaration simpler
Greg Hurrell [Sun, 20 Mar 2016 08:06:23 +0000 (01:06 -0700)] 
Make FunctionDeclaration simpler

No contents; just the abstract token.

6 years agoShow one way to match fu(n(c(t(i(o(n?)?)?)?)?)?)?
Greg Hurrell [Sun, 20 Mar 2016 08:02:39 +0000 (01:02 -0700)] 
Show one way to match fu(n(c(t(i(o(n?)?)?)?)?)?)?

All the backtracking via `try` is probably not very efficient, so I will
show another way to do this presently (or at least, I intend to).

6 years agoGradually start reworking VimL parsing
Greg Hurrell [Sun, 20 Mar 2016 07:57:50 +0000 (00:57 -0700)] 
Gradually start reworking VimL parsing

Starting at "function".

6 years agoSplit into executable and library
Greg Hurrell [Sun, 20 Mar 2016 07:26:47 +0000 (00:26 -0700)] 
Split into executable and library

Apparently all the cool kids are doing it.

6 years agoAdd tasty tests
Greg Hurrell [Sun, 20 Mar 2016 06:02:09 +0000 (23:02 -0700)] 
Add tasty tests

   cabal install --enable-tests
   cabal configure --enable-tests
   cabal test

6 years agoSet up test suite for running HLint from cabal
Greg Hurrell [Sun, 20 Mar 2016 05:44:23 +0000 (22:44 -0700)] 
Set up test suite for running HLint from cabal

With:

    cabal test

After one-time set-up:

    cabal configure --enable -tests

6 years agoFix hlint nits
Greg Hurrell [Sun, 20 Mar 2016 05:25:22 +0000 (22:25 -0700)] 
Fix hlint nits

Mostly unnecessary parens, plus one unnecessary `$`.

6 years agoUse parseTest
Greg Hurrell [Sun, 20 Mar 2016 05:00:51 +0000 (22:00 -0700)] 
Use parseTest

6 years agoStart really parsing VimL
Greg Hurrell [Sun, 20 Mar 2016 04:59:27 +0000 (21:59 -0700)] 
Start really parsing VimL

6 years agoAdd support for @function annotation
Greg Hurrell [Sat, 19 Mar 2016 21:32:11 +0000 (14:32 -0700)] 
Add support for @function annotation

6 years agoAdd some more stuff to the parser
Greg Hurrell [Sat, 19 Mar 2016 02:34:01 +0000 (19:34 -0700)] 
Add some more stuff to the parser

6 years agoTidy up parser a little
Greg Hurrell [Sat, 19 Mar 2016 00:43:00 +0000 (17:43 -0700)] 
Tidy up parser a little

6 years agoGrow parser
Greg Hurrell [Sat, 19 Mar 2016 00:19:32 +0000 (17:19 -0700)] 
Grow parser

Applying some things I learned in the lexer to the parser. If I can pull
the parser off without having to split into lexer + parser I will. Seems
the best way to avoid jumping through hoops to get better error
messages:

http://stackoverflow.com/questions/15216202

6 years agoSimplify content-free token constructors
Greg Hurrell [Fri, 18 Mar 2016 16:02:40 +0000 (09:02 -0700)] 
Simplify content-free token constructors

These have fixed content in them, so we don't need to record it.

6 years agoUnify an import statement
Greg Hurrell [Fri, 18 Mar 2016 16:02:40 +0000 (09:02 -0700)] 
Unify an import statement

6 years agoTeach lexer to recognize a few more token types
Greg Hurrell [Fri, 18 Mar 2016 16:02:40 +0000 (09:02 -0700)] 
Teach lexer to recognize a few more token types

6 years agoAdd some cheatsheet info to the README
Greg Hurrell [Fri, 18 Mar 2016 16:02:40 +0000 (09:02 -0700)] 
Add some cheatsheet info to the README

6 years agoAdd separate lexer
Greg Hurrell [Fri, 18 Mar 2016 16:01:23 +0000 (09:01 -0700)] 
Add separate lexer

I think this will likely end up being simpler in the long run, so
trying it out for now.

6 years agoDon's export parseUnit
Greg Hurrell [Fri, 18 Mar 2016 15:28:30 +0000 (08:28 -0700)] 
Don's export parseUnit

Now that we export `p`, we don't need it.

6 years agoFacilitate testing in the REPL with `p`
Greg Hurrell [Fri, 18 Mar 2016 14:31:34 +0000 (07:31 -0700)] 
Facilitate testing in the REPL with `p`

6 years agoUse simpler char rather than string parser
Greg Hurrell [Fri, 18 Mar 2016 14:23:24 +0000 (07:23 -0700)] 
Use simpler char rather than string parser

6 years agoStep towards actually parsing comments
Greg Hurrell [Fri, 18 Mar 2016 14:21:41 +0000 (07:21 -0700)] 
Step towards actually parsing comments

6 years agoMake filter lambda point-free
Greg Hurrell [Fri, 18 Mar 2016 06:31:49 +0000 (23:31 -0700)] 
Make filter lambda point-free

6 years agoSlightly neaten conditional logging
Greg Hurrell [Fri, 18 Mar 2016 06:02:37 +0000 (23:02 -0700)] 
Slightly neaten conditional logging

6 years agoLog filenames when -v is passed
Greg Hurrell [Fri, 18 Mar 2016 05:59:44 +0000 (22:59 -0700)] 
Log filenames when -v is passed

There are surely neater ways to do this (a monad for logging as we go),
but this is it for now.

6 years agoSplit out Parse module
Greg Hurrell [Fri, 18 Mar 2016 05:46:49 +0000 (22:46 -0700)] 
Split out Parse module

6 years agoPrep to move parsing into separate module
Greg Hurrell [Fri, 18 Mar 2016 05:41:31 +0000 (22:41 -0700)] 
Prep to move parsing into separate module

6 years agoParse to EOF
Greg Hurrell [Fri, 18 Mar 2016 05:30:23 +0000 (22:30 -0700)] 
Parse to EOF

6 years agoStart build out more AST types
Greg Hurrell [Fri, 18 Mar 2016 05:11:09 +0000 (22:11 -0700)] 
Start build out more AST types

6 years agoPass contents of file through parsec
Greg Hurrell [Fri, 18 Mar 2016 03:48:45 +0000 (20:48 -0700)] 
Pass contents of file through parsec

6 years agoRemove Paths_docvim.hs hack
Greg Hurrell [Thu, 17 Mar 2016 21:43:26 +0000 (14:43 -0700)] 
Remove Paths_docvim.hs hack

Not needed. Can just use `cabal repl` instead of `ghci`.

6 years agoSwitch doc comment ordering
Greg Hurrell [Thu, 17 Mar 2016 20:55:21 +0000 (13:55 -0700)] 
Switch doc comment ordering

I prefer to keep the type right next to the function.

6 years agoActually read from file system
Greg Hurrell [Thu, 17 Mar 2016 20:54:22 +0000 (13:54 -0700)] 
Actually read from file system

As noted, some potential danger here, but we'll worry
about it later:

https://mail.haskell.org/pipermail/beginners/2010-October/005569.html

6 years agoActually respect -c command-line option
Greg Hurrell [Thu, 17 Mar 2016 20:38:46 +0000 (13:38 -0700)] 
Actually respect -c command-line option

6 years agoFilter out non-Vim source files
Greg Hurrell [Thu, 17 Mar 2016 20:35:02 +0000 (13:35 -0700)] 
Filter out non-Vim source files

6 years agoImprove variable name
Greg Hurrell [Thu, 17 Mar 2016 20:25:26 +0000 (13:25 -0700)] 
Improve variable name

6 years agoStub out reading in current directory
Greg Hurrell [Thu, 17 Mar 2016 20:24:56 +0000 (13:24 -0700)] 
Stub out reading in current directory

6 years agoSplit options parsing into a separate file
Greg Hurrell [Wed, 16 Mar 2016 16:07:44 +0000 (09:07 -0700)] 
Split options parsing into a separate file

6 years agoAdd hack so that we can :load src/Main.hs in ghci
Greg Hurrell [Wed, 16 Mar 2016 14:48:26 +0000 (07:48 -0700)] 
Add hack so that we can :load src/Main.hs in ghci

Without this, we fail to find the Paths_docvim module.

6 years agoAdd missing type annotations
Greg Hurrell [Wed, 16 Mar 2016 14:48:20 +0000 (07:48 -0700)] 
Add missing type annotations

6 years agoShow default value for -c option
Greg Hurrell [Wed, 16 Mar 2016 14:32:36 +0000 (07:32 -0700)] 
Show default value for -c option

6 years agoParse --verbose and OUTFILE arguments
Greg Hurrell [Wed, 16 Mar 2016 14:32:14 +0000 (07:32 -0700)] 
Parse --verbose and OUTFILE arguments

6 years agoFormat
Greg Hurrell [Wed, 16 Mar 2016 14:31:26 +0000 (07:31 -0700)] 
Format

6 years agoCorrect typo in help output
Greg Hurrell [Wed, 16 Mar 2016 14:08:44 +0000 (07:08 -0700)] 
Correct typo in help output

6 years agoAdd --version flag
Greg Hurrell [Wed, 16 Mar 2016 14:05:01 +0000 (07:05 -0700)] 
Add --version flag

Google search for how to use `infoOption` led to this:

https://github.com/fujimura/git-freq/blob/12d38a1f9109d307e420acc7facc85e425bb6349/src/Main.hs

Cargo-culted it from there.

6 years agoDefault to running in the current directory
Greg Hurrell [Wed, 16 Mar 2016 07:14:12 +0000 (00:14 -0700)] 
Default to running in the current directory

6 years agoSplit out option parsing functions
Greg Hurrell [Wed, 16 Mar 2016 06:57:14 +0000 (23:57 -0700)] 
Split out option parsing functions

This might make things a little more readable.

6 years agoRename "{C,c}onfig" to "{O,o}ptions"
Greg Hurrell [Wed, 16 Mar 2016 05:54:05 +0000 (22:54 -0700)] 
Rename "{C,c}onfig" to "{O,o}ptions"

6 years agoRename "intro" to "run"
Greg Hurrell [Wed, 16 Mar 2016 05:52:32 +0000 (22:52 -0700)] 
Rename "intro" to "run"

6 years agoAdd starting point for options parsing
Greg Hurrell [Tue, 15 Mar 2016 15:36:09 +0000 (08:36 -0700)] 
Add starting point for options parsing

Based on sample in docs at:

https://hackage.haskell.org/package/optparse-applicative#readme

I will go through and add more options in a later pass. This article has
a nice overview of how things should be structured:

https://robots.thoughtbot.com/applicative-options-parsing-in-haskell

6 years agoAdd type annotation to main
Greg Hurrell [Tue, 15 Mar 2016 14:53:35 +0000 (07:53 -0700)] 
Add type annotation to main

As this is a learning exercise, let's be explicit about types.

6 years agoIgnore built files in "dist/"
Greg Hurrell [Tue, 15 Mar 2016 14:52:14 +0000 (07:52 -0700)] 
Ignore built files in "dist/"

I suppose this is the right thing to do.

6 years agoStart Haddock-generated documentation
Greg Hurrell [Tue, 15 Mar 2016 14:49:59 +0000 (07:49 -0700)] 
Start Haddock-generated documentation

Produce it via `cabal haddock --executables`.

Required me to add an explicit `module ... where` declaration before it
would parse the file.

6 years agoAdd executable
Greg Hurrell [Tue, 15 Mar 2016 14:40:30 +0000 (07:40 -0700)] 
Add executable

This is our "Hello, world!". Runs with `cabal run`.

6 years agoRun cabal init
Greg Hurrell [Tue, 15 Mar 2016 14:34:40 +0000 (07:34 -0700)] 
Run cabal init

This is the result of running `cabal init` as per:

http://jabberwocky.eu/2013/10/24/how-to-start-a-new-haskell-project/

and cleaning up:

- Fix whitespace errors in docvim.cabal.
- Add "description" field.
- Update LICENSE reference to LICENSE.md, as I already had that.

6 years agoAdd README and LICENSE
Greg Hurrell [Tue, 15 Mar 2016 14:16:22 +0000 (07:16 -0700)] 
Add README and LICENSE

Resetting the master branch and restarting development in Haskell.