hoaproject / Compiler

The Hoa\Compiler library.
https://hoa-project.net/
453 stars 48 forks source link

Parsing tree is just the first token #101

Closed vasily-kartashov closed 5 years ago

vasily-kartashov commented 5 years ago

When running this grammar https://github.com/hamlet-framework/type/blob/master/src/Reader/grammar.pp

against this test set: https://github.com/hamlet-framework/type/blob/master/tests/Reader/ParserTest.php

the output is:

\Hamlet\Cast\Type
>  token(id, \Hamlet\Cast\Type)
array
>  token(array, array)
int
>  token(built_in, int)
array<string, array<string, array{DateTime}>>
>  token(array, array)
array|null|false|1|1.1
>  token(array, array)
array{id:int|null,name?:string|null}
>  token(array, array)
('a'|'b'|'c')
>  token(string:string, a)
'a'|'b'
>  token(string:string, a)
string[][]
>  token(built_in, string)
(1|false)[]
>  token(int_number, 1)
(A::FOO | A::BAR)
>  token(id, A)
int[]
>  token(built_in, int)
callable(('a'|'b'), int):(string|array{\DateTime}|callable():void)
>  token(callable, callable)
array{0: string, 1: string, foo: stdClass, 28: false}
>  token(array, array)
A::class|B::class
>  token(id, A)
Closure(bool):int
>  token(id, Closure)
array<string,\DateTime>
>  token(array, array)
Generator<T0, int, mixed, T0>
>  token(id, Generator)
Generator<T0, int, mixed, T0> & object
>  token(id, Generator)

What is the output not the complete tree but just the first token?

vasily-kartashov commented 5 years ago

Missing # in front of matching rules.