You've now seen a bunch of these token definitions,
one for words, one for strings.
A lexical analyzer or lexer--this is a term of art--
is just a collection of such tokens.
You tell me what makes a word, what makes a string,
what makes a number, what makes white space.
You put it all together, and the result is a lexer,
something that splits a string into exactly
the token definitions you've given it.
For example, once I put these 3 rules together,
they become a lexer, or lexical analyzer.
And in fact, suppose we passed to this lexical analyzer
the input string 33 is less than 55.
Oh, gentle student, tell to me which one of these
token output sequences could result.
In this multiple choice quiz,
indicate which of these 3 possible output lists
could correspond to the values of the tokens
extracted from this input string using these rules.
Let's put it all together.
ここまでトークンの定義をたくさん見てきました
単語や文字列の定義です
専門用語である字句解析プログラムとは
単にトークンが集まったものを意味します
単語、文字列、数字、ホワイトスペースの
トークンの定義を書いて
すべて並べたら字句解析プログラムです
これは文字列を正確に
皆さんが定義したトークンに分割します
例えばこの3つの定義を一緒にすると
これらは字句解析プログラムになります
実際にこのプログラムを使って
入力文字列33 is less than 55を
字句解析してみます
ここで皆さんにはどのトークンのシーケンスが
出力されるか考えていただきます
ここで選択式の小テストです
次の3つの出力リストのどれが
入力文字列から抽出されたトークンの値に
相当するでしょうか?
一緒に考えてみましょう
Você já viu várias definições de tokens,
uma para palavras, outra para strings.
Um analisador léxico ou lexer,
é simplesmente uma colação desses tokens.
Você me diz o que é uma palavra, um string,
um número, espaços em branco ...
Você junta isso tudo, e o resultado é um lexer --
algo que separa um string em exatamente
as definições de tokens que você forneceu para ele.
Por exemplo, uma vez que colocamos estas 3 regras juntas,
elas se tornam um lexer, ou analisador léxico.
De fato, suponha que passamos para esse analisador léxico
o string de entrada "33 is less than 55".
Oh, diga-me quais dessas
sequências de tokens pode resultar como saída.
Neste teste de múltipla escolha,
indique qual destas 3 possíveis saídas
poderia corresponder aos valores dos tokens
extraídos deste string de entrada, usando estas regras.
Vamos juntar isso tudo.