Questions tagged [lexical]

The "Lexical" tag is used to denote a connection with words of a language, its grammar or the dictionary. Alternatively, it is also used in the context of "lexical scope," the context in which certain values are valid.

Broadly, Lexical is used to refer to words of a language. (The terms in applicable to natural (human) languages, as well as to computer programming languages. Lexical is derived from "Lexicon" and therefore the tag is also applied to questions relating to the dictionary for a language.

Finally, the tag is used in a computer programming context: Lexical Scoping. A lexical scope is the "context" within with certain rules/values apply (Example the "scope" of a local variable.)

204 questions
7
votes
2 answers

Need an end of lexical scope action which can die normally

I need the ability to add actions to the end of a lexical block where the action might die. And I need the exception to be thrown normally and be able to be caught normally. Unfortunately, Perl special cases exceptions during DESTROY both by…
Schwern
  • 153,029
  • 25
  • 195
  • 336
7
votes
2 answers

Reusing MySQL parser

I'm working on SQL intrusion detection system (IDS) and I need do parse incoming SQL queries. Writing own SQL parser is a long term task and it will never exactly reflect the logic used in native parser. I found out that MySQL has a lexical analyzer…
bittomix
  • 171
  • 1
  • 9
7
votes
2 answers

Does PHP have lexical scope in anonymous functions / closures?

I'm using PHP 5.4 and wondering if the anonymous functions I'm making have lexical scoping? I.e. If I have a controller method: protected function _pre() { $this->require = new Access_Factory(function($url) { $this->redirect($url); …
Charles
  • 1,029
  • 1
  • 11
  • 15
7
votes
1 answer

What is the advantage of lexical addressing in Chapter 5 of SICP?

I am reading SICP now and don't really understand the necessity of lexical addressing described in 5.5.6 Lexical addressing of SICP. Since it says "Because our language is lexically scoped, the run-time environment for any expression will have a…
user1461328
  • 742
  • 2
  • 6
  • 13
6
votes
2 answers

How does JavaScript's lexical environment maintain variables declarations within nested block scopes?

I've read a couple of more comprehensive articles on the execution context and now I am sort of confused and messed up in the head. To keep the question as brief as possible avoiding long citations I better try to illustrate my mental model through…
fekaloid
  • 195
  • 1
  • 2
  • 9
6
votes
4 answers

Why can't I use a Perl variable's value to access a lexical variable name?

Why does this print 42: $answer = 42; $variable = "answer"; print ${$variable} . "\n"; but this doesn't: my $answer = 42; my $variable = "answer"; print ${$variable} . "\n";
ennuikiller
  • 46,381
  • 14
  • 112
  • 137
6
votes
1 answer

Flex prints newline to stdout on default rule match - want to alter that behavior

I have the following flex rules in place. "#"{name} {printf(" HASH | %s\n", yytext);} . {} It works great for my purposes and outputs upon a match to the first rule; HASH | some matched string What's bothering…
inetplumber
  • 173
  • 7
6
votes
3 answers

What is meant by proper closure here

This is a code lifted straight from Perl Cookbook: @colors = qw(red blue green yellow orange purple violet); for my $name (@colors) { no strict 'refs'; *$name = sub { "@_" }; } It's intention is to form 6 different…
SexyBeast
  • 7,913
  • 28
  • 108
  • 196
5
votes
2 answers

Is it possible to have hard real-time with lexical scope?

I was reading this paper about the funarg problem, which is really the problem of maintaining the environments of lexical closures. It's an old paper and I'm not sure if the author's conclusions still hold, but he strongly implies that, in order to…
Johnny
  • 51
  • 1
5
votes
2 answers

Haskell: lexical error in string/character literal at character 'i'

I'm fairly new to Haskell programming and I'm having trouble understanding why I'm receiving this error in my code. My problem is as follows: Any positive integer i can be expressed as i = 2^n*k, where k is odd, that is, as a power of 2 times an odd…
Gus
  • 115
  • 1
  • 2
  • 4
5
votes
2 answers

About lexical scoping in R

I am fairly new to R and while I was reading the manuals I came across a passage about lexical scoping along with this code example: open.account <- function(total) { list( deposit = function(amount) { if(amount <= 0) …
Katana
  • 103
  • 2
  • 8
5
votes
3 answers

When should you use a package variable vs a lexical variable (and what's the difference)?

I'm looking at some older Perl code on Perl Monks to figure out programming with Win32::OLE and MS Word. Scattered throughout the code are variables with names like $MS::Word and the like, without a 'my' included in their declaration. After reading…
romandas
  • 4,086
  • 7
  • 29
  • 33
4
votes
5 answers

Simple Method to a Simple Parser

I'm trying to create a simple parser and a small text file which follows the following structure: Variable_name = Value; VARIABLE_2 = SECOND_VALUE; Found methods that work, however, use many librarys like Boost. I wonder if you can make a simple,…
Bruno Alano
  • 643
  • 1
  • 11
  • 21
4
votes
2 answers

new Java 8+ separators (punctuators) - how/where are they used?

The JLS for Java 8 introduces three new separators: ... @ :: The ellipsis (...) is used as "last formal parameter of a method or constructor". But already the JLS for Java 7 described this formal parameter as variable arity parameter. It isn't…
LuCio
  • 5,055
  • 2
  • 18
  • 34
4
votes
2 answers

Writing Compilers, Lexical Analysis?

I'm completely new to writing compilers. So I am currently starting the project (coded in Java), and before coding, I would like to know more about the lexical analysis part. I have researched on the web, I found out that most of them use…
gerky
  • 6,267
  • 11
  • 55
  • 82
1
2
3
13 14