The base language of Nemerle

118 views
Skip to first unread message

David Piepgrass

unread,
Apr 18, 2013, 12:01:11 PM4/18/13
to Nemerle Forum
I would like to understand the Nemerle base language and compiler
architecture. I found this document, are there any others on these
subjects?

https://github.com/rsdn/nemerle/wiki/Nemerle-language-%28part-6%29

This document states: "the compiler actually parses a more abstract
language than is specified by the syntax of Nemerle. For example,
imagine the compiler parsing references to a certain type. What it
actually does is not parsing the syntax of a reference but rather the
syntax of a Nemerle’s expression. Later, when the compiler begins
typing the obtained AST (the abstract syntax tree), it will check
whether the parsed expression matches the type of the reference and
will report an error if it does not."

I don't understand. Could someone explain by way of example?

Also, what is the parsing model of Nemerle--what parts is the parser
divided into? Could I see a dataflow diagram? Can the parser
"understand" Nemerle code to some extent when some of the references
are missing (e.g. missing macro DLL), or does it fail completely? For
example, presumably lexical analysis still works even without macro
DLLs; can the parser still do anything else?

P.S. Who is still working on Nemerle? (I asked Michal Moskal--he and
Kamil Skalski are no longer working on Nemerle.) Who was hired by
JetBrains?

Thanks!

NN

unread,
Apr 18, 2013, 3:19:15 PM4/18/13
to nemer...@googlegroups.com
Hello.

Unfortunately you have more articles in russian than in english language. (You can use google translate or www.translate.ru if it works better)
Here you have a lot of articles:  http://www.rsdn.ru/summary/3766.xml
Articles about macros explain a lot what happens inside compiler .

I didn't understand your question about parsing.

David Piepgrass

unread,
Apr 21, 2013, 12:18:24 AM4/21/13
to Nemerle Forum
My question is simply, how does parsing work in Nemerle? It obviously
doesn't work like other languages, because you can create your own
syntax.

Soooooo... I read through that "part 6" documentation, but I didn't
learn very much. Does any other information exist about Nemerle's base
language? And what would a program look like that does not use any
macros?

Also, I am curious whether pattern matching is a macro, or built-in.

NN

unread,
Apr 21, 2013, 4:38:08 AM4/21/13
to nemer...@googlegroups.com
Hello
You should read this article and other parts too: http://nemerle.org/Macros_-_extended_course._Part_1

Nemerle has special compiler step : PreParse.
The parser and lexer reside in files: Lexer.n , MainParser.n and PreParser.n

pattern matching is built in.

VladD2

unread,
Apr 23, 2013, 4:14:13 AM4/23/13
to nemer...@googlegroups.com
Hi

2013/4/18 David Piepgrass <qwert...@gmail.com>

I would like to understand the Nemerle base language and compiler
architecture. I found this document, are there any others on these
subjects?

https://github.com/rsdn/nemerle/wiki/Nemerle-language-%28part-6%29

 
This document states: "the compiler actually parses a more abstract
language than is specified by the syntax of Nemerle. For example,
imagine the compiler parsing references to a certain type. What it
actually does is not parsing the syntax of a reference but rather the
syntax of a Nemerle’s expression. Later, when the compiler begins
typing the obtained AST (the abstract syntax tree), it will check
whether the parsed expression matches the type of the reference and
will report an error if it does not."

I don't understand. Could someone explain by way of example?

If you write:
def foo(x : X[Y]) { }
the parser parse the "X[Y]" as a general expression.
For example, you can write:
def foo(x : X(Y)) { }
Nemerle paresr recognize it.
Unfortunatly, this code does not pass type check. But a macro can read this code and rewrite it or generate new code.

 
Also, what is the parsing model of Nemerle--what parts is the parser
divided into?

  • Lexer - Tokenize text. Work together with PreParser to get additional keywords.
  • PreParser - Rolls tokens by brackets and load synax extension. Produces token tree.
  • MainParser - Parse token tree and produces parse tree.
  • Typer - Expands macros, type expansion result and produce typed tree.
 
Can the parser
"understand" Nemerle code to some extent when some of the references
are missing (e.g. missing macro DLL), or does it fail completely?

It is fail. Macro is a compiler plugin.
 
P.S. Who is still working on Nemerle?

 
Who was hired by JetBrains?

We work on extansible language framework. It is written on Nemerle. And it is will be used to write next wersion of Nemerle.
Reply all
Reply to author
Forward
0 new messages