· Регистрация 
софт скрипты драйвера форумы блоги  
Пример: windows
Софт
Новости софта
Обзоры
Статьи
Авторам
Софт
Mac Linux PDA/Mobile
Linux Программирование Интерпретаторы

Страница программы Flex 2.5.33

Flex is a Fast Lexical Analyzer.


  Описание программы   Комментарии (0)   Скриншоты (0)   Файлы (1)  
АвторVern Paxson
СайтПерейти
Обновление15.02.2007, 04:11
НазваниеFlex
ВерсияFlex 2.5.33
ЯзыкиАнглийский
ЛицензияGPL (GNU GPL)
СтоимостьБесплатно
СистемыLinux
Размер?
Рейтинг
Голосов: 1

Скачать бесплатно Flex
Закачек: 15
найти или купить на Allsoft.ru
софт в Allsoft.ru 




Описание программы Flex
Flex is a Fast Lexical Analyzer.
Flex is a fast lexical analyzer generator. It is a tool for generating programs that perform pattern-matching on text. Flex is a non-GNU free implementation of the well known Lex program.
Flex is a tool for generating scanners: programs which recognized lexical patterns in text. flex reads the given input files, or its standard input if no file names are given, for a description of a scanner to generate. The description is in the form of pairs of regular expressions and C code, called rules. flex generates as output a C source file, `lex.yy.c', which defines a routine `yylex()'. This file is compiled and linked with the `-lfl' library to produce an executable. When the executable is run, it analyzes its input for occurrences of the regular expressions. Whenever it finds one, it executes the corresponding C code.
Some simple examples
First some simple examples to get the flavor of how one uses flex. The following flex input specifies a scanner which whenever it encounters the string "username" will replace it with the user's login name:
%%
username printf( "%s", getlogin() );
By default, any text not matched by a flex scanner is copied to the output, so the net effect of this scanner is to copy its input file to its output with each occurrence of "username" expanded. In this input, there is just one rule. "username" is the pattern and the "printf" is the action. The "%%" marks the beginning of the rules.
Here's another simple example:
int num_lines = 0, num_chars = 0;
%%
n ++num_lines; ++num_chars;
. ++num_chars;
%%
main()
{
yylex();
printf( "# of lines = %d, # of chars = %dn",
num_lines, num_chars );
}
This scanner counts the number of characters and the number of lines in its input (it produces no output other than the final report on the counts). The first line declares two globals, "num_lines" and "num_chars", which are accessible both inside `yylex()' and in the `main()' routine declared after the second "%%". There are two rules, one which matches a newline ("n") and increments both the line count and the character count, and one which matches any character other than a newline (indicated by the "." regular expression).
A somewhat more complicated example:
/* scanner for a toy Pascal-like language */
%{
/* need this for the call to atof() below */
#include < math.h >
%}
DIGIT [0-9]
ID [a-z][a-z0-9]*
%%
{DIGIT}+ {
printf( "An integer: %s (%d)n", yytext,
atoi( yytext ) );
}
{DIGIT}+"."{DIGIT}* {
printf( "A float: %s (%g)n", yytext,
atof( yytext ) );
}
ifthenbeginendprocedurefunction {
printf( "A keyword: %sn", yytext );
}
{ID} printf( "An identifier: %sn", yytext );
"+""-""*""/" printf( "An operator: %sn", yytext );
"{"[^}n]*"}" /* eat up one-line comments */
[ tn]+ /* eat up whitespace */
. printf( "Unrecognized character: %sn", yytext );
%%
main( argc, argv )
int argc;
char **argv;
{
++argv, --argc; /* skip over program name */
if ( argc > 0 )
yyin = fopen( argv[0], "r" );
else
yyin = stdin;
yylex();
}
This is the beginnings of a simple scanner for a language like Pascal. It identifies different types of tokens and reports on what it has seen.
The details of this example will be explained in the following sections.
· Ключевые особенности и характеристики Flex 2.5.33
Не определены
· Ограничения Flex 2.5.33
Ограничения не определены
· Специальные требования Flex 2.5.33
Специальные требования не определены
· История версий и изменений Flex
История пуста
· Описание и дополнения от редакторов и пользователей сайта
Пока нет
Связанные статьи, обзоры и новости
Нет относящихся к программе статей и обзоров.


Другие программы от Vern Paxson
Больше не найдено программ этого автора.
     
Похожие программы

Php Logo Interpreter 0.1
Php Logo Interpreter project is a logo language interpreter.
29.05.2007, 01:34 | ? | GPL (GNU GPL) | 11


Spoon for Java 1.2
Spoon is a Java program processor that fully supports Java 5.
10.05.2007, 02:37 | ? | LGPL | 4


NullLogic Embedded Scripting Language 0.6.0
NullLogic Embedded Scripting Language code looks a lot like php but with a lot less dollar signs.
26.04.2007, 05:35 | ? | GPL (GNU GPL) | 2


SMUSHcode 20030211
SMUSHcode project is a functional (as opposed to procedural) scripting language interpreter, written in Java.
09.03.2007, 03:12 | ? | GPL (GNU GPL) | 1


MicroTiger 1.00.0001
MicroTiger is a graphical microcode simulator with a reconfigurable datapath.
07.03.2007, 06:20 | ? | GPL (GNU GPL) | 1

Разделы