rubyx/lib/parser
Nigel Thorne 20433e3ad2 Change to NigelThorne fork to detect infinite loops
and fixed grammar to ignore missing parameter list.
2014-06-04 21:48:32 +10:00
..
basic_types.rb add instance variables and module name as basic types (as name was there already) and add tests 2014-05-30 14:25:08 +03:00
call_site.rb had forgotten calls on instance variables. corrected + tests 2014-06-01 14:46:16 +03:00
compound_types.rb fix the spurious root expression and add conmound types back (thanks to kasper for fixing that) 2014-05-27 15:36:51 +03:00
control.rb add some return test to functions 2014-05-27 16:51:37 +03:00
crystal.rb Change to NigelThorne fork to detect infinite loops 2014-06-04 21:48:32 +10:00
expression.rb add some return test to functions 2014-05-27 16:51:37 +03:00
function_definition.rb Change to NigelThorne fork to detect infinite loops 2014-06-04 21:48:32 +10:00
keywords.rb define modules and tests, no compiling 2014-05-29 15:57:33 +03:00
module_definition.rb Change to NigelThorne fork to detect infinite loops 2014-06-04 21:48:32 +10:00
operators.rb introduce constant class and add block to compile signature(wip, work in progress) 2014-05-13 16:24:19 +03:00
README.markdown add a simple return, ie the normal kind, not with trailing statements 2014-05-27 16:33:24 +03:00
tokens.rb a good stab at array anf hash constants 2014-05-12 21:36:38 +03:00
transform.rb add qualification to function definitions 2014-06-02 14:00:30 +03:00

Parser

This includes the parser and generated ast.

Parslet is really great in that it:

  • does not generate code but instean gives a clean dsl to define a grammar
  • uses ruby modules so one can split the grammars up
  • has support for binary operators with presedence and binding
  • has a seperate tranform stage to generate an ast layer

Especially the last point is great. Since it is seperate it does not clutter up the actual grammar. And it can generate a layer that has no links to the actual parser anymore, thus saving/automating a complete tranformation process.

Operator list from http://stackoverflow.com/questions/21060234/ruby-operator-precedence-table

N A M Operator(s) Description


1 R Y ! ~ + boolean NOT, bitwise complement, unary plus (unary plus may be redefined from Ruby 1.9 with +@)

2 R Y ** exponentiation 1 R Y - unary minus (redefine with -@)

2 L Y * / % multiplication, division, modulo (remainder) 2 L Y + - addition (or concatenation), subtraction

2 L Y << >> bitwise shift-left (or append), bitwise shift-right 2 L Y & bitwise AND

2 L Y | ^ bitwise OR, bitwise XOR (exclusive OR) 2 L Y < <= >= > ordering

2 N Y == === != =~ !~ <=> equality, pattern matching, comparison (!= and !~ may not be redefined prior to Ruby 1.9)

2 L N && boolean AND 2 L N || boolean OR

2 N N .. ... range creation (inclusive and exclusive) and boolean flip-flops

3 R N ? : ternary if-then-else (conditional) 2 L N rescue exception-handling modifier

2 R N = assignment 2 R N **= *= /= %= += -= assignment 2 R N <<= >>= assignment 2 R N &&= &= ||= |= ^= assignment

1 N N defined? test variable definition and type 1 R N not boolean NOT (low precedence) 2 L N and or boolean AND, boolean OR (low precedence) 2 N N if unless while until conditional and loop modifiers