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.)

175 questions
108
votes
9 answers

Is there a JavaScript equivalent of the Python pass statement that does nothing?

I am looking for a JavaScript equivalent of the Python: pass statement that does not run the function of the ... notation? Is there such a thing in JavaScript?
user781486
  • 20,909
  • 45
  • 145
  • 253
26
votes
6 answers

Making a lexical Analyzer

I'm working with a Lexical Analyzer program right now and I'm using Java. I've been researching for answers on this problem but until now I failed to find any. Here's my problem: Input: System.out.println ("Hello World"); Desired…
KLoverated
  • 271
  • 1
  • 3
  • 6
19
votes
4 answers

The good, the bad, and the ugly of lexical $_ in Perl 5.10+

Starting in Perl 5.10, it is now possible to lexically scope the context variable $_, either explicitly as my $_; or in a given / when construct. Has anyone found good uses of the lexical $_? Does it make any constructs simpler / safer /…
Eric Strom
  • 38,995
  • 2
  • 75
  • 150
11
votes
5 answers

Why does Programming Perl use local (not my) for filehandles?

When I read through Programming Perl, 2nd Edition, Page 51, something confuses me : sub newopen { my $path = shift; local *FH; #not my! open (FH, $path) || return undef; return *FH; } $fh = newopen('/etc/passwd'); My I know, why…
Cheok Yan Cheng
  • 49,649
  • 117
  • 410
  • 768
11
votes
1 answer

How to parse sentences based on lexical content (phrases) with Python-NLTK

Can Python-NLTK recognize input string and parse it not only based on white space but also on the content? Say, "computer system" became a phrases in this situation. Can anyone provide a sample code? input String: "A survey of user opinion of…
user3381299
  • 157
  • 1
  • 6
10
votes
1 answer

Common Lisp scoping (dynamic vs lexical)

EDIT: I changed the example code after the first answer because I came up with a simple version that begs the same questions. I am currently learning Common Lisp's scoping properties. After I thought I had a solid understanding I decided to code up…
Anthony Naddeo
  • 2,239
  • 17
  • 19
9
votes
1 answer

Does Perl v5.18's sort understand lexical subroutines?

This is fixed in Perl v5.22. Does Perl v5.18's lexical subroutines with sort? I finally had a use for them today where I had a complicated sorting routine that depends on the current position in the data structure to look at deeper parts. Here's a…
brian d foy
  • 121,466
  • 31
  • 192
  • 551
8
votes
1 answer

What is the difference between Lexical grammar and Syntactic grammar?

I am reading The Java Language Specification 8. I am trying to understand Chapter 2. Grammars. Here's what I have already learned: Semantics: Semantics is the study of meaning. Meaning: Meaning, in semantics, is defined as being Extension: The…
Rounak
  • 577
  • 1
  • 7
  • 21
7
votes
4 answers

Lexical Scope in JavaScript

I am slightly confused as to how exactly scope works in JavaScript, mainly lexical scope. I understand that variables in global scope are accessible anywhere, and the only way to create a new scope in JavaScript is through the creation of functions…
E. Sawyers
  • 85
  • 1
  • 9
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
  • 127,817
  • 21
  • 150
  • 290
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
  • 889
  • 1
  • 7
  • 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
  • 730
  • 1
  • 5
  • 11
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
  • 173
  • 1
  • 1
  • 6
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
  • 43,779
  • 13
  • 108
  • 136
1
2 3
11 12