lexical

Common Lisp scoping (dynamic vs lexical)

天大地大妈咪最大 提交于 2019-12-02 19:37:45
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 some examples that I could predict the outcome of, but apparently I was wrong. I have three question, each one relating to an example below: Example 1: (defmethod fun1 (x) (print x) (fun2)) (defmethod fun2 () (print x)) (fun1 5) Output: 5 *** - EVAL: variable X has no value Question: This makes sense. x is statically scoped and fun2 has no way of

Lexical error: Encountered: “” (0), after : “”

泄露秘密 提交于 2019-12-02 00:29:48
问题 I needed to start dealing with foreign characters, and in doing so, I think I royally screwed up a file's encoding. The error I'm getting is: Lexical error at line 1, column 8. Encountered: "" (0), after : "" The first line of the file is: import xml.etree.cElementTree as ET Also of note: when I pasted the line above into the textarea to ask this question, and submitted, an unknown character appeared between every character (e I have been unable to fix this issue by adding an explicit coding

MIT Java WordNet Interface: Getting WordNet lexicographer classes or super-senses

不问归期 提交于 2019-11-30 16:23:27
问题 I have a project where I need to get the lexical meaning of a word. I am thinking of using WordNet because it has its own lexicographer classes also called super-senses. I just downloaded MIT JWI and trying to see if this JWI does support it. The manual doesn't say anything about returning any lexical information attached to the word. import java.io.File; import java.io.IOException; import java.io.ObjectInputStream.GetField; import java.net.URL; import edu.mit.jwi.*; import edu.mit.jwi.item

Lexical Scope in JavaScript

我们两清 提交于 2019-11-30 14:25:21
问题 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 (or with let in ES6). However, I do not really understand what lexical scope is/means. I have looked all over the internet and could not find a clear explanation. I feel like I am kind of starting to understand it, but just let me confirm with you

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

╄→гoц情女王★ 提交于 2019-11-29 23:35:25
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 / faster? What about situations that it makes more complicated? Has the lexical $_ introduced any bugs into your code? (since control structures that write to $_ will use the lexical version if it is in scope, this can change the behavior of the code if it contains any subroutine calls (due to loss of dynamic scope)) In the end, I'd like to construct a list

C++ parser generator [closed]

六眼飞鱼酱① 提交于 2019-11-29 12:03:05
I'm writing my own scripting language and I need a software tool which generates C++ code for parsing my language. I need a lexical analyzer and a parser generator which generates C++ code. It would be nice for me to be able also to generate a Visual C++ 2010 project. Suggestions? Try with Flex and Bison. They are good lexical analizers and parser generator usefull to define new languages. http://en.wikipedia.org/wiki/Flex_lexical_analyser http://en.wikipedia.org/wiki/Comparison_of_parser_generators for C/C++: http://epaperpress.com/lexandyacc/ Or look at: Boost.Spirit: "Spirit is a set of C++

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

懵懂的女人 提交于 2019-11-29 08:32:14
问题 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 computer system response time" Expected output : ["A", "survey", "of", "user", "opinion", "of", "computer system", "response", "time"] 回答1: The technology you're looking for is called multiple names from multiple sub-fields or sub-sub-fields of

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

こ雲淡風輕ζ 提交于 2019-11-29 00:52:04
问题 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 we are not recommenced to use my? So far, I cannot see anything will go wrong if we use my(). Thanks! 回答1: The trite answer is that you have to use local because my *FH is a syntax error. The "right" (but not very enlightening) answer is that you're doing it wrong.

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

旧巷老猫 提交于 2019-11-28 20:22:44
问题 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 / faster? What about situations that it makes more complicated? Has the lexical $_ introduced any bugs into your code? (since control structures that write to $_ will use the lexical version if it is in scope, this can change the behavior of the code if it

Making a lexical Analyzer

我的梦境 提交于 2019-11-28 15:55:25
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 Output: Lexeme----------------------Token System [Key_Word] . [Object_Accessor] out [Key_Word] . [Object_Accessor] println [Key_Word] ( [left_Parenthesis] "Hello World" [String_Literal] ) [right_Parenthesis] ; [statement_separator] I'm still a beginner so I hope you guys can help me on this. Thanks. You need neither ANTLR nor the Dragon book to write a simple lexical