Law.
[Latin lēx, lēg-.]
Dictionary:
lex (lĕks) ![]() |
[Latin lēx, lēg-.]
| 5min Related Video: lex |
| Computer Desktop Encyclopedia: yacc |
(Yet Another Compiler Compiler) A Unix compiler used to create a compiler. The operators, variables and constants of the program are typically defined in C using lex (LEXical analyzer), which converts them into preprocessed, machine-readable tokens for yacc. The grammar of the new language is written in C and compiled in yacc. The combination of lex (define elements) and yacc (define actions) creates a new compiler. For more information, visit www.epaperpress.com. See bison.
Download Computer Desktop Encyclopedia to your iPhone/iTouch
| Thesaurus: lex |
| Law Encyclopedia: Lex |
[Latin, Law.] In medieval jurisprudence, a body or collection of various laws peculiar to a given nation or people; not a code in the modern sense, but an aggregation or collection of laws not codified or systematized. Also, a similar collection of laws relating to a general subject, and not peculiar to any one people.
In modern U.S. and English jurisprudence this term signifies a system or body of laws, written or unwritten, applicable to a particular case or question regarded as local or unique to a particular state, country, or jurisdiction.
| Wikipedia: Lex (software) |
In computer science, lex is a program that generates lexical analyzers ("scanners" or "lexers").[1] Lex is commonly used with the yacc parser generator. Lex, originally written by Eric Schmidt and Mike Lesk, is the standard lexical analyzer generator on many Unix systems, and a tool exhibiting its behavior is specified as part of the POSIX standard.
Lex reads an input stream specifying the lexical analyzer and outputs source code implementing the lexer in the C programming language.
Though traditionally proprietary software, versions of Lex based on the original AT&T code are available as open source, as part of systems such as OpenSolaris and Plan 9 from Bell Labs. Another popular open source version of Lex is Flex, the "fast lexical analyzer".
Contents |
The structure of a lex file is intentionally similar to that of a yacc file; files are divided up into three sections, separated by lines that contain only two percent signs, as follows:
Definition section %% Rules section %% C code section
The following is an example lex file for the flex version of lex. It recognizes strings of numbers (integers) in the input, and simply prints them out.
/*** Definition section ***/
%{
/* C code to be copied verbatim */
#include <stdio.h>
%}
/* This tells flex to read only one input file */
%option noyywrap
%%
/*** Rules section ***/
/* [0-9]+ matches a string of one or more digits */
[0-9]+ {
/* yytext is a string containing the matched text. */
printf("Saw an integer: %s\n", yytext);
}
. { /* Ignore all other characters. */ }
%%
/*** C Code section ***/
int main(void)
{
/* Call the lexer, then quit. */
yylex();
return 0;
}
If this input is given to flex, it will be converted into a C file, lex.yy.c. This can be compiled into an executable which matches and outputs strings of integers. For example, given the input:
abc123z.!&*2ghj6
the program will print:
Saw an integer: 123 Saw an integer: 2 Saw an integer: 6
Lex and Yacc (a parser generator) are commonly used together. Yacc uses a formal grammar to parse an input stream, something which Lex cannot do using simple regular expressions (Lex is limited to simple finite state automata). However, Yacc cannot read from a simple input stream - it requires a series of tokens. Lex is often used to provide Yacc with these tokens.
make is a utility that can be used to maintain programs involving lex. Make assumes that a file that has an extension of .l is a lex source file. The make internal macro LFLAGS can be used to specify lex options to be invoked automatically by make.[2]
This entry is from Wikipedia, the leading user-contributed encyclopedia. It may not have been reviewed by professional editors (see full disclaimer)
| Shopping: lex |
| jurisprudence | |
| jurisdiction | |
| talion |
| Are their differences between lex mark 17 and lex mark 16? | |
| How did lex get paralazed? | |
| What was Lex Luger's sentence? |
Copyrights:
![]() | Dictionary. The American Heritage® Dictionary of the English Language, Fourth Edition Copyright © 2007, 2000 by Houghton Mifflin Company. Updated in 2009. Published by Houghton Mifflin Company. All rights reserved. Read more | |
![]() | Computer Desktop Encyclopedia. THIS COPYRIGHTED DEFINITION IS FOR PERSONAL USE ONLY. All other reproduction is strictly prohibited without permission from the publisher. © 1981-2009 Computer Language Company Inc. All rights reserved. Read more | |
![]() | Thesaurus. Roget's II: The New Thesaurus, Third Edition by the Editors of the American Heritage® Dictionary Copyright © 1995 by Houghton Mifflin Company. Published by Houghton Mifflin Company. All rights reserved. Read more | |
![]() | Law Encyclopedia. West's Encyclopedia of American Law. Copyright © 1998 by The Gale Group, Inc. All rights reserved. Read more | |
![]() | Wikipedia. This article is licensed under the Creative Commons Attribution/Share-Alike License. It uses material from the Wikipedia article "Lex (software)". Read more |
Mentioned in