Hoa central
Public Member Functions | List of all members
Hoa\Compiler\Test\Unit\Documentation Class Reference
Inheritance diagram for Hoa\Compiler\Test\Unit\Documentation:

Public Member Functions

 case_whole_process ()
 
- Public Member Functions inherited from Hoa\Test\Unit\Suite
 __construct ()
 
 getTestedClassName ()
 
 getTestedClassNamespace ()
 
 beforeTestMethod ($methodName)
 

Detailed Description

Class .

Test suite of the examples in the documentation.

Definition at line 51 of file Documentation.php.

Member Function Documentation

Hoa\Compiler\Test\Unit\Documentation::case_whole_process ( )

Definition at line 53 of file Documentation.php.

54  {
55  $_grammar = <<<GRAMMAR
56 %skip space \s
57 // Scalars.
58 %token true true
59 %token false false
60 %token null null
61 // Strings.
62 %token quote_ " -> string
63 %token string:string [^"]+
64 %token string:_quote " -> default
65 // Objects.
66 %token brace_ {
67 %token _brace }
68 // Arrays.
69 %token bracket_ \[
70 %token _bracket \]
71 // Rest.
72 %token colon :
73 %token comma ,
74 %token number \d+
75 
76 value:
77  <true> | <false> | <null> | string() | object() | array() | number()
78 
79 string:
80  ::quote_:: <string> ::_quote::
81 
82 number:
83  <number>
84 
85 #object:
86  ::brace_:: pair() ( ::comma:: pair() )* ::_brace::
87 
88 #pair:
89  string() ::colon:: value()
90 
91 #array:
92  ::bracket_:: value() ( ::comma:: value() )* ::_bracket::
93 GRAMMAR;
94  $_result = <<<GRAMMAR
95 > #object
96 > > #pair
97 > > > token(string:string, foo)
98 > > > token(true, true)
99 > > #pair
100 > > > token(string:string, bar)
101 > > > #array
102 > > > > token(null, null)
103 > > > > token(number, 42)
104 
105 GRAMMAR;
106 
107  $this
108  ->given(
109  $grammar = new File\ReadWrite('hoa://Test/Vfs/Json.pp'),
110  $grammar->writeAll($_grammar),
111  $compiler = LUT\Llk::load($grammar)
112  )
113  ->when($ast = $compiler->parse('{"foo": true, "bar": [null, 42]}'))
114  ->then
115  ->object($ast)
116 
117  ->given($dump = new LUT\Visitor\Dump())
118  ->when($result = $dump->visit($ast))
119  ->then
120  ->string($result)
121  ->isEqualTo($_result);
122  }

The documentation for this class was generated from the following file: