improved readmes
This commit is contained in:
parent
720a3f6168
commit
cc96f5a0e8
@ -1,7 +1,15 @@
|
||||
Parser
|
||||
================
|
||||
## Crystal Reader*
|
||||
|
||||
This includes the parser and generated ast.
|
||||
The parser part of crystal is now a standalone gem. It parses ruby using Parslet and no other dependencies.
|
||||
|
||||
This is interesing if you want to generate executable code, like crystal, but also for other things, like code analysis.
|
||||
|
||||
Also it is very educational, as it is very readable code, and not too much of it.
|
||||
|
||||
*
|
||||
It looks into it's crystal ball and all it sees is red. A red crystal . . . ruby code, yes.
|
||||
|
||||
### Parslet
|
||||
|
||||
Parslet is really great in that it:
|
||||
- does not generate code but instean gives a clean dsl to define a grammar
|
||||
@ -13,6 +21,10 @@ Especially the last point is great. Since it is seperate it does not clutter up
|
||||
And it can generate a layer that has no links to the actual parser anymore, thus saving/automating
|
||||
a complete tranformation process.
|
||||
|
||||
### Operators
|
||||
|
||||
Parslets operator support is **outstanding** and such it was a breeze to implement most of rubies operators very simply. See the operators.rb for details. Below is a list from the web of how it should be.
|
||||
|
||||
|
||||
Operator list from http://stackoverflow.com/questions/21060234/ruby-operator-precedence-table
|
||||
|
@ -1,5 +1,17 @@
|
||||
Parsing
|
||||
-------
|
||||
##Running Tests
|
||||
|
||||
To run all tests, type
|
||||
|
||||
ruby test/test_all.rb
|
||||
|
||||
to run just a single, replace all with what you want to test. Minitest accept a -n option to run just a single test. So while developing i often write things like
|
||||
|
||||
ruby test/test_class.rb -n test_class_ops_parse
|
||||
|
||||
Notice tough the _parse at the end, while you will find no such function. The Magic (explained below) renerates three
|
||||
functions per case. Your options are _parse , _tranform , or if it's really bad, _ast (this should really work when the previous two work)
|
||||
|
||||
###Parsing
|
||||
|
||||
Some sanity is emerging in the testing of parsers
|
||||
(Parsers are fiddly in respect to space and order, small changes may and do have unexpected effects)
|
||||
@ -14,8 +26,7 @@ Each test must thus specify (as instance variables):
|
||||
- the parse output
|
||||
- the transform output
|
||||
|
||||
Magic
|
||||
-----
|
||||
### Magic
|
||||
|
||||
Test are grouped by functionality into cases (classes) and define methods test_*
|
||||
Test cases must include ParserHelper, which includes the magic to write the 3 test methods for each
|
||||
@ -35,4 +46,8 @@ The last line tells the parser what to parse. This is off couse only needed when
|
||||
and should be left out if possible.
|
||||
|
||||
As can be seen, there are no asserts. All asserting is done by the created methods, which call
|
||||
the check_* methods in helper.
|
||||
the check_* methods in helper.
|
||||
|
||||
### Negative tests
|
||||
|
||||
Notice there are no test to test how the parser fails. In other words test of grammar it does not understand, or that isn't even ruby. Such things would be nice off course, but it's early days.
|
Loading…
Reference in New Issue
Block a user