Layout in Rascal

人走茶凉 提交于 2019-12-02 06:03:25

When you define a start non-terminal Rascal defines two non-terminals in one go:

rascal>start syntax A = "a";
ok

One non-terminal is A, the other is start[A]. Given a layout non-terminal in scope, say L, the latter is automatically defined by (something like) this rule:

syntax start[A] = L before A top L after;

If you call a parser or wish to parse a concrete fragment, you can use either non-terminal:

parse(#start[A], " a ") // parse using the start non-terminal and extra layout
parse(A, "a") // parse only an A
(start[A]) ` a ` // concrete fragment for the start-non-terminal
(A) `a` // concrete fragment for only an A
[start[A]] " a "
[A] "a"
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!