Код: Выделить всё
kinds
name test_val_1
length ten test_val_2
uses
use1 testcase_1
use2 testcase_2
Я пробовал приведенную ниже грамматику, но узлы не вложены, как ожидалось.
Код: Выделить всё
grammar Test;
test : entry (NEWLINE+ entry)* NEWLINE* EOF;
entry : label;
label : KEY_OR_VALUE (SPACE value)*;
nestedEntry : label;
value : KEY_OR_VALUE+;
KEY_OR_VALUE : [a-zA-Z_]+[a-zA-Z_0-9.]*;
SPACE : [ ]+;
NEWLINE : [\r\n]+;
Код: Выделить всё
- kinds should be the root node under which the child nodes are name, length and uses
- name should have another child node having the value separated by a space after name, in the example that will be test_val_1
- length node should have two child nodes, that are ten and test_val_2 in the above example
- uses should have two child nodes, that are use1 and use2 which in turn will have the child nodes testcase_1 and testcase_2 respectively.
[img]https://i .sstatic.net/6cmgkQBM.png[/img]
Как видите, дерево синтаксического анализа работает не так, как ожидалось.
Любые предложения по поводу того, что может быть, нужно исправить мою грамматику?
Подробнее здесь: https://stackoverflow.com/questions/791 ... -structure