ПО, ЭВМ и АСУ из Таможенного Союза

Информация о пользователе

Привет, Гость! Войдите или зарегистрируйтесь.


Вы здесь » ПО, ЭВМ и АСУ из Таможенного Союза » контекстно-зависимые грамматики » Проблема макропроцессоров (Makefile-ов в частности)


Проблема макропроцессоров (Makefile-ов в частности)

Сообщений 1 страница 2 из 2

1

Как мы видим, не только практика весьма запутана, но и теории не хватает (т.е. не знания теории, а сама она не проработана).

http://www.conifersystems.com/whitepapers/gnu-make/

You can’t parse a makefile without also executing it. Variable substitution can happen almost anywhere, and if you don’t know the value of a variable, you can’t continue parsing. It is challenging to write other tools that can parse makefiles, because you must reimplement the whole language.

в принципе, такая же (или только похожая?) ситуация должна быть с препроцессором в языке C.

Давно бы пора уже придумать какую-нибудь формальную модель для этого, но всем слабо.

https://en.wikipedia.org/wiki/General-p … _processor
тут мы видим, что малой кровью не обойтись, потому что макропроцессоры - это некислые по размеру движки типа T4, внутри которых собственный язык типа C#.

Я уже писал раньше про склеивание входов и выходов, но комментарии как-то не порадовали...

Можно ли (и как именно) сделать препроцессор используя лево-контекстную грамматику?
https://en.wikipedia.org/wiki/Context-sensitive_grammar

The left-context- and right-context-sensitive grammars are defined by restricting the rules to just the form αA → αγ and to just Aβ → γβ, respectively. The languages generated by these grammars are also the full class of context-sensitive languages. The equivalence was established by Penttonen normal form.

http://www.ml1.org.uk/htmldoc/ml1diss.h … Dependence

It might be desired to know whether or not a macro call occurs within a base language subroutine, what the name of the current "control section" is, whether or not the call is within a DO loop and, if so, what the controlled variable is, and so on. It is clearly impractical for the user to supply extra arguments to macro calls in order to pass all this information across. Indeed the information might not be known at the time the macro call was written. Hence the macro processor should glean all the required information for itself by examining the appropriate base language statements and remembering information by setting macro variables.

To achieve this, a macro is defined with the same syntax as the base language statement so that each occurrence of the base language statement results in a call of the macro. The action of the macro is to set those macro variables that are used to keep a record of the base language statements and to replace the macro call by a copy of itself so that the original text is not changed.

Пишет нам из 1968-го года P.J. Brown. И где научный прогресс за 50 лет?

Каким бы я его хотел видеть? Я хочу открыть учебник и прочитать там: "Если вы хотите реализовать контекстно-зависимый парсинг кода для макропроцессора, вам следует взять такую матмодель..." (тут некоторые скажут "на лиспе таких проблем нет", зато там есть другие)

Отредактировано Лис (2018-04-09 05:07:48)

0

2

Мне всегда лень было XML-ки ворочать, они такие толстые бывают, а вот в них-то чаще всего и спрятаны те "изюминки", до которых надо докопаться. - Вот сижу, кумекаю...

0


Вы здесь » ПО, ЭВМ и АСУ из Таможенного Союза » контекстно-зависимые грамматики » Проблема макропроцессоров (Makefile-ов в частности)