Concrete as editor for EBNF defined languages

135 views
Skip to first unread message
Message has been deleted

Marcin Stefaniuk

unread,
Mar 13, 2011, 9:27:53 AM3/13/11
to Concrete Model Editor
I would start with great appreciation of Concrete editor features and
author's work.

Last days I've created few tiny languages using metamodel editor. I've
also tried DOM templates and CSS customization. I've achieved positive
results for modeling DSLs (with entities, properties and references
between them).

Is it possible to use Concrete to flow languages (these defined with
EBNF) where position gives information what kind of entity's property
is set?

Regards
Marcin Stefaniuk

mthiede

unread,
Mar 15, 2011, 5:50:24 PM3/15/11
to Concrete Model Editor
Hello Marcin,

yes, you can define such EBNF like languages in Concrete.
For something like

Mult = Expr "*" Expr

you would have to create a class "Mult" which has two containment
features "expr1" and "expr2" which each can take an instance of class
"Expression" (which would be the super class of all expression classes
including "Mult". then in the DOM template, you would not use lables
"expr1" and "expr2" but merely the pure value and thus the position to
distinguish between them.

see ther formula editor for an example:
http://concrete-editor.org/concrete/example/formula_editor/formula_editor.html

One issue with this is that primitive values like numbers (1, 2, ..)
can not be instances of class "Expression" and thus you can not
directly put them where you would put other expression. Instead, there
has to be something like a "PrimitiveExpression" which has an
attribute "value" which then can take values like 1,2,..
This is due to the underlying ecore meta-metamodel. Also see the
formula editor example for this.

Another issue is that it can be cumbersome to create those kinds of
expression with the current editing mechanisms of Concrete.
(Especially with things like the first issue stated above)
Also see my other post on Concrete and Xtext:
http://groups.google.com/group/concrete-editor/browse_thread/thread/c70b8935b4f8f93c

Besides a potential future Xtext to Concrete converter, there could be
a simple converter which takes EBNF expressions and generates both
metamodel in json and the dom templates. So you would be able to
define your Concrete language in EBNF.

For the usability/editing issue, I was also thinking about something
like an interactive parser.
There could be a special edit mode where users can create a set of
model elements at once.
While users would type expressions like "(2 * 4) + x" in Concrete,
Concrete could act like a LL parser and construct the model elements
on the fly.
Of course the grammar would have to fit.

Any thoughts or help on this is very welcome.

Martin

Marcin Stefaniuk

unread,
Mar 24, 2011, 6:16:42 PM3/24/11
to Concrete Model Editor
Thank you for answering. During last few days I checked using language
parser in JavaScript. I found promising library PEG.js (http://
pegjs.majda.cz/online) that allows to easily build AST tree or build a
working language in JS.
Currently I work on XPath parser to provide users autocompleting of
nodes when editing an expression - it should work similar as reference
in Concrete. I have positive result so I can attempt to prepare parser
from text to Concrete model.

Regards

mthiede

unread,
Mar 25, 2011, 6:26:47 PM3/25/11
to Concrete Model Editor
PEG.js definitely looks interesting.
However,I don't fully understand what you are trying to do.
Do you want to parse XPath expressions with PEG.js, then use the AST
to build up a Concrete model and then use Concrete for editing and
auto completion?
Or are you trying to build a separate tool which is just similar to
Concrete?

Marcin Stefaniuk

unread,
Mar 25, 2011, 7:32:52 PM3/25/11
to Concrete Model Editor
Currently I'm working on simple XPath editor with node autocompletion.
Originally I considered Concrete as a base but XPath is complex when
edition is AST based. So I decided to use PEG.js with simple
evaluation in it that helps generating hints when XML model is
provided.
I consider interesting bi-mode editing of models - in Concrete and
PEG.js. Maybe I would prepare an example of it (basing on State
mashine). Additionally as editor base http://codemirror.net/ can be
used with autocomplete feature (http://codemirror.net/2/demo/
complete.html).
Reply all
Reply to author
Forward
0 new messages