O
O
Oxoron2016-07-12 18:43:21
Programming
Oxoron, 2016-07-12 18:43:21

Who can advise the literature on syntax trees?

Good afternoon.
There is a self-written console tool with its own query language. There is a task: to write a script for creating requests to the tool in C#. I know how to make an ExpressionTree in C#, I can imagine how to write a syntax node in Roslyn. How to implement a similar mechanism for your own language?
Roughly speaking, there is a query "Get fullLine from storage Trash where Source is "Universe" and inputDate moreThan 2016-07-12".
You need a lib that allows you to generate queries in the form
of Query.New.
GetAll().From("Trash")
.Filter("Source", FilterType.Equal, "Universe")
.Filter("inputDate", FilterType.MoreThan, new DateTime(2016,7,12))
.Result;
If you manage to somehow screw in LINQ, it's generally gorgeous.
var query = Storage.Where(row => row.Source == "Universe")
.Where(row => row.inputDate > new DateTime(2016,7,12))
.ToList();
Where to dig? Will I need syntax trees to solve? If so, what literature would you recommend?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
abcd0x00, 2016-07-14
@Oxoron

Will I need syntax trees to solve? If so, what literature would you recommend?

There is a classic book by Aho, Ulman "The Theory of Parsing, Translation and Compilation".
In fact, you need a translator from one language to another. You can’t learn from a book, but for development you need to know the theory, especially if you need to do this. It will not be possible to write there using the guessing game method, since it has a multi-stage structure, where everything must be done in order.

M
Michael, 2016-07-12
@Madfisht3

Linq uses extension methods. For example System.Linq.Enumerable. what hinders to write the methods extending?

A
Alexander Taratin, 2016-07-12
@Taraflex

https://ru.wikipedia.org/wiki/%D0%9E%D0%B1%D1%80%D...
Для наглядности расставим скобки
((Get fullLine) from (storage Trash)) where ((Source is "Universe") and (inputDate moreThan 2016-07-12))
Переводим в польскую
((fullLine Get) (Trash storage ) from ) ((Source "Universe" is) (inputDate 2016-07-12 moreThan ) and ) where
Полученная запись легко может быть преобразована в нужный код раскручиванием стека

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question