Лексический анализ языка программирования Python

Это кажется близко к тому, что Вы хотите:

#foo {
  background: red;
  max-height: 100px;
  overflow-y: hidden;
}

.bar {
  background: blue;
  width: 100px;
  height: 100px;
  float: left;
  margin: 1em;
}
<div id="foo">
  <div class="bar"></div>
  <div class="bar"></div>
  <div class="bar"></div>
  <div class="bar"></div>
  <div class="bar"></div>
  <div class="bar"></div>
</div>
7
задан Jed Smith 14 November 2009 в 00:46
поделиться

3 ответа

Lex is typically just used for tokenizing, not full parsing. Projects that use flex/lex for tokenizing typically use yacc/bison for the actual parsing.

You may want to take a look at ANTLR, a more "modern" alternative to lexx & yacc.

The ANTLR Project has a Github repo containing many ANTLR 4 grammars including at least one for Python 3.

6
ответ дан 7 December 2019 в 03:17
поделиться

grammar.txt is the official, complete Python grammar -- not directly lex compatible, but you should be able to massage it into a suitable form.

3
ответ дан 7 December 2019 в 03:17
поделиться

Have you considered using one of the existing code highlighters, like Pygments?

0
ответ дан 7 December 2019 в 03:17
поделиться
Другие вопросы по тегам:

Похожие вопросы: