w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
difference between Source code parser and Grammar parser
The phrase "source code parser" by itself is clear enough: this is a mechanism that parses source text, using either a parser-generator engine based off of a formal grammar or some kind of hand-coded (typically recursive descent) parser derived from the grammar informally. It is unclear what the result of a "source code parser" is from just the phrase; it might just be "yes, that's valid syntax", more usually "produces a parse or abstract syntax tree", or it might be (sloppily) "full abstract syntax tree plus symbol table plus control and dataflow analyses". The phrase "grammar parser" is not one I encounter much (and I work a lot in this field). It is likely something garbled from some other source. In the absence of a widely known definition, one would guess that this means a) a "

Categories : Misc

WebBrowser Read Viewer code and not Source Code
It sounds like you do not have PHP set up correctly on the server. When you go to the page ( http://www.mywebsite/ip2.php ) does the source code show up there as well? What server software are you running?

Categories : C#

How to use ~> and <~ in grammar rule definition in Scala?
I found the solution, I should break typeDefBody to 3 None terminal rules as below def typeDefBody = ident ~ typeDefBodySequence1 def typeDefBodySequence1 = ":" ~> ident ~ typeDefBodySequence2 def typeDefBodySequence2 = "{" ~> fieldBody <~ "}" def fieldBody = "validation" ~ "{" ~> validationBody <~ "}" def validationBody = length ~ pattern def length = "length" ~ "=" ~> wholeNumber ~ "to" ~ wholeNumber def pattern = "pattern" ~ "=" ~> stringLiteral

Categories : Scala

Cant read file within source code
The problem here is that when you run your program in Eclipse, the code is run from the directory containing the code, whereas Jenkins runs it from some other directory. Thus, ./ does not refer to the directory containing the code. You can use the getResourceAsStream method to load resources from locations in your classpath, and apparently deals with JAR bundling too. This article on resource loading should explain things somewhat. However, this method should only really be used for files that the user never needs to interact with. If you want to store a user-edited configuration file, for example, it should be put somewhere else, such as an Application Data directory.

Categories : Java

Any suggestion on how to read Symfony2 source code?
Before diving into Symfony2 source code, I would suggest starting with Create your own framework... on top of the Symfony2 Components serie of 12 articles. It explains well the role of each component and the way they can be used.

Categories : Symfony2

Scala spark Matrix operations
This will be covered by the MLbase project and the MLI API which will integrated in Spark. This is still in early stage but you can find an example of Linear Regression here.

Categories : Scala

getting a grammar to read more than one keyword in the text
I'm good with TDD, but here your whole testing and alternative-selecting infrastructure really gets in the way of seeing just where the grammar is and what's going on with it. If I strip away all the extra machinery, I see your grammar is just: kw = Combine(Word(alphas + nums) + Literal(';'))('KEY') body1 = delimitedList(OneOrMore(Word(alphas + nums)) +~kw)('Body') g1 = OneOrMore(Group(kw + body1)) The first issue I see is your definition of body1: body1 = delimitedList(OneOrMore(Word(alphas + nums)) +~kw)('Body') You are on the right track with a negative lookahead, but for it to work in pyparsing, you have to put it at the beginning of the expression, not at the end. Think of it as "before I match another valid word, I will first rule out that it is a keyword.": body1 = delimitedL

Categories : Python

How to convert linux/mac source code into windows vs2010 source code?
Maybe this resource may help you (I used it once): http://docs.opencv.org/doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.html Porting code is often a hard task that one has to face on some day :D

Categories : C++

Source Code Repository Software Choice for Storing Source Code (Not for Dev)
Short answer: ANY Longer answer All mentioned SCMs support linear history without problems, have sufficient ACLs. DVCS, contrary to CVCS, just doesn't require from you to have and support additional central repository-server, independent from you workplace (if it matter)

Categories : GIT

Is there a general way to convert an unambiguous context-free-grammar into a LALR(1) grammar?
1 . Are there any general ways to convert such non-LALR(1) grammars into LALR(1) grammars? No. It may or may not be possible to convert an arbitrary context-free grammar (CFG) into an LALR(1) grammar. There is no general algorithm to do so, even if you somehow know that it is possible. Moreover, if you have a CFG and an LALR(1) grammar, you cannot tell whether they recognize the same language. (Worse, there is no algorithm which will even tell you whether an arbitrary CFG recognizes every possible string for its alphabet.) 2 . If two grammars generate exactly the same languages and we know that one is not LALR(1), can we know if the other is LALR(1)? Again, no. As above, there is no algorithm which can verify that two grammars generate the same language, but even supposing that

Categories : Algorithm

Remove all annotations in Java source code and get new source code
I ended up using JEdit which has brilliant regular expression support. I wanted to replace specific annotations (I wanted to keep stuff like @Override). You can easily do that for all buffers or a directory tree. Just write some simple expressions for the annotations you want to remove. For example ^s*@NamedQueries( {[^}]+})

Categories : Java

How do we define a grammar for clojure code using instaparse?
Well there are two parts to your question. The first part is parsing the expression (+ 1 2 (+ 3 4)) The second part is transforming the output to the result that you want. To get a good understanding of these principles, I highly recommend Udacity's Programming Languages course. Carin Meier's blog post is also quite helpful. The best way to understand how the parser will work, is to break it down into smaller parts. So in the first we'll just examine some parsing rules, and in the second part we'll build our sexps. A simple example You will first need to write a grammar that tells instaparse how to parse the given expression. We'll start by just parsing the number 1: (def parser (insta/parser "sexp = number number = #'[0-9]+' ")) sexp describes

Categories : Clojure

ANTLR: How the behavior of this grammar which recognizes suffixes of a Java code can be explained?
I think that you will find that it is not backtracking in the manner that you expect. The reason is that it finds the {} and then expects to see a v2_181, which it doesn't find. because it doesn't then backtrack, it doesn't find the alternative that you want. The alternative is to just make the v2_181 optional, then you don't need the backtracking. Something like below: grammar Java; @parser::members {String ruleName; } start : compilationUnitSuf EOF; compilationUnitSuf : {ruleName = "typeDeclarationSuf"; } s2 ; s2: '{' '}' v2_81?; v2_81 : {ruleName.equals("enumBodyDeclarationsSuf")}? t173 | t173 '}'; t173: '}' | '{'*; LBRACKET: '{'; RBRACKET: '}'; WS : [ u000C]+ -> skip ;

Categories : Java

Why are some functions declared extern and header file not included in source in Git source code?
strbuf.c includes cache.h and cache.h includes strbuf.h, so your premise for question 2 (that strbuf.c does not include strbuf.h) is wrong: it does include it, just not directly. extern applied to functions The extern keyword is never required for function declarations, but it does have an effect: it declares that the identifier naming the function (i.e., the function's name) has the same linkage as any previously visible declaration, or if no such declaration is visible, that the identifier has external linkage. This rather confusing phrasing really means that, given: static int foo(void); extern int foo(void); the second declaration of foo also declares it static, giving it internal linkage. If you write: static int foo(void); int foo(void); /* ERROR */ you have declared it fir

Categories : C

Open Source CMS in java for web content managment with source code to develop in eclipse for custom changes
Well, dotCMS provides the features that you are looking for like using servlets to build your own stuff on top of their API's. Have you tried their dotcms_2.3.1.exe windows installer? It includes the database stuff and everything and should work. If it doens't you can ask questions on their google group page (https://groups.google.com/group/dotcms) and most likely there will be somebody that can help you out.

Categories : Java

Spark Standalone Mode: How to compress spark output written to HDFS
The method saveAsTextFile takes an additional optional parameter of the codec class to use. So for your example it should be something like this to use gzip: someMap.saveAsTextFile("hdfs://HOST:PORT/out", classOf[GzipCodec]) UPDATE Since you're using 0.7.2 you might be able to port the compression code via configuration options that you set at startup. I'm not sure if this will work exactly, but you need to go from this: conf.setCompressMapOutput(true) conf.set("mapred.output.compress", "true") conf.setMapOutputCompressorClass(c) conf.set("mapred.output.compression.codec", c.getCanonicalName) conf.set("mapred.output.compression.type", CompressionType.BLOCK.toString) to something like this: System.setProperty("spark.hadoop.mapred.output.compress", "true") System.setProperty("spark.h

Categories : Scala

view source code is not showing up on view source code when I use in within update panel
The View Source option shows you exactly that - the original source code for the page. If you want to see any elements what were added dynamically to the page, you have to view the current DOM structure. You can do that using tools like the IE Developer tools, the Firefox Inspector, or the Firefox plugin Firebug.

Categories : Asp Net

How can i read a json file in chromium source code using chromium in-built json parser
You're probably looking for https://code.google.com/p/chromium/codesearch#chromium/src/base/json/json_reader.h&sq=package:chromium&type=cs.

Categories : Json

What is the use of "Spark" in the sample code provided at google plus quick start for java
import static spark.Spark.get; This is called static import . The static import declaration imports static members from classes and allowing them to be used without class reference. And as per the Google site: Spark is a Sinatra inspired micro web framework for Java. And the SparkJava documentation says : It is micro web framework for quickly creating web applications in Java with minimal effort. Spark's intention is not to compete with Sinatra, or the dozen of clones in different languages (Grafitti, Nancy, Flask, Sammy etc...). Its intention is to be used by Java developers that want or are required to develop in pure Java. Spark focuses on being as simple and straight-forward as possible, without the need for cumbersome (XML) configuration, to enable very fast web ap

Categories : Java

Play source file "Reads.scala" use of generalized type constraint
This is because this type witness is also a function. It is declared in Predef as: sealed abstract class <:<[-From, +To] extends (From => To) with Serializable So A <:< JsValue is also a function (A) => JsValue. You might wonder what the function does: it does nothing, it takes an A and directly returns it (as a JsValue). To see why this is useful consider this example: sealed trait Root { def bip() { println("bip") } } def makeBip[A <: Root](a: A) { a.bip() // works because a is known to the type system to be a Root } def makeBip2[A](a: A)(implicit ev: A <:< Root) { a.bip() // works, because implicit resolution turns it into `ev(a).bip()` } The last method makeBip2 would not compile without the implicit because even though you know that a is a Root

Categories : Scala

What is the equivalent scala code to this python code: "%i" % float(9.04E09)
The Java way: (see here as well Java parse a number in exponential notation) java.lang.Double.valueOf("9.04E09").longValue() Another way in Scala: "9.04E09".toDouble.longValue Or "9.04E09".toDouble.formatted("%.0f")

Categories : Scala

If I use SSLSocket in Android and hard code the passcode to the truststore in the source code is that insecure?
I haven't tried on Android, but here is how it works in plain Java. You're using your keystore as a truststore here, so (hopefully) it doesn't contain any private key or secret material. In this case, the purpose of the password is to verify the integrity of the store. From the Keystore.load(InputStream, char[]) documentation: A password may be given to unlock the keystore (e.g. the keystore resides on a hardware token device), or to check the integrity of the keystore data. If a password is not given for integrity checking, then integrity checking is not performed. Either you use null as the password (in which case you'll always be able to load the certificates) or you use a non-null char array with the actual password (in which case an incorrect password will fail with some

Categories : Java

How can I convince Eclipse CDT that a macro is defined for source code editing and code completion?
Found it: Project -> Properties -> C/C++ General -> Paths and Symbols Choose the Symbols tab and Add... a new Symbol with Name I_WANT_THIS_FEATURE and a Value of 1.

Categories : Eclipse

Git strategy needed to get an old source code in Git and manage it to have a single point to maintain code
The usual way is to create a repository for each codebase. Putting unrelated code into one big repository dilutes the benefits of source control. Following your comment I think what you should look at are git submodules. It gives you a single repository which you can share with other repositories. Also, if you make a change to the common code in one project you can push this to the master repository where it is the available to other repositories should they wish to use the changes.

Categories : GIT

Get code of a specific user define function or class from a source code
What you need is basically a parser, so that you can pick out structures of interest. Then you either use the position information such a parser gathers (if it is well designed), to determine the boundaries of the text in your file to extract that structure, or you "prettyprint" the AST of the parsed structure to get your artifact. NikiC describes his search and eventual construction of one such parser in PHP in this SO question. There are other solutions provided there, including mine, but it isn't in PHP. You may have some trouble picking out the exact function you want. Imagine you have a file with two classes C1 and C2, each containing a method named M. Now to select the "right method", you need to have the full path C1::M available, and you need to check that the method M is fou

Categories : PHP

where is the tegra's hardware codec code in android source code(4.1)
The libstagefrighthw library is simply "glue" code that patches vendor proprietary media framework with libstagefright framework within Android. This approach is used to implement hardware specific custom codecs. The qcom, ti code you see, is the one that got sync-ed into the "mainline" Android repository quite sometime back. For tegra-specific code, you will need to get your hands on a proper Tegra development repository. (This maybe?) You may also want to checkout the Tegra3 libstagefrighthw code within the CM 10.2 repo.

Categories : Android

Maintaining source code and testing code in a single git repository
I think branch is the answer, if I undertood correct. Why? If the "specific modifications" are few, I understand that could be a lot of code in common between "source code" version and "test" version. In this case, you will need sometimes to correct/update the same code in both versions, and will be useful a "hotfix" branch that you will merge in the "source code" and "test" branch. Update 1 - Create a testing_code branch from master (where you already have this files), like: git branch -b testing_code master 2 - When you need to do some correction in the common code, you can create a "hotfix_whatever" branch, from testing_code or master, like: git branch -b hotfix_whatever master 3 - Do the correction in hotfix_whatever and merge in master and testing_code. Merge in testing_code

Categories : GIT

How to get source code after simulate web page button click in code
A hacky approach would be to: Attach an event handler to the 'onclick' event of the button. Then, once the event is triggered, use the Microsoft Internet Controls (SHDocVw) type library in order to get the last URL opened in IE. Lastly, navigate to the URL and once the document is loaded, get the source of the document from the webBrowser1.DocumentText property. In your project, add a reference to the Microsoft Internet Controls type library (you'll find it in the COM tab). Add at the top of your file: using SHDocVw; The code: webBrowser1.Navigate(url); while (webBrowser1.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); } // assign the button to a variable var button = webBrowser1.Document.GetElementById("downloadButton"); // attach an event handler for

Categories : C#

How can I read a CSV file and put its content in a Map in Scala?
You could skip the intermediary List of tuple and just build the map directly like this: val result: Map[String, Array[String]] = data.filter(e => !e.isEmpty).map(e => (e.head,e.tail))(collection.breakOut) Not sure if this will fix your issue though, but you did ask if there was another way to build the map. You can read more about collection.breakOut here: Scala: List[Tuple3] to Map[String,String]

Categories : Scala

Converting Java code to Scala code
Varargs Varargs in scala is Seq, not Array. So objs can't be an instance of Array[MyClass1]. Actually you could get an Array like this: def test(s: Any*) = s match { case wa: WrappedArray[_] => wa.array case _ => ??? } But you'll get an Array[_], not an Array[MyClass1]: scala> test("a", "b", "c").isInstanceOf[Array[String]] res0: Boolean = false You could check all elements of Array and then convert Array[_] to Array[MyClass1], but I don't think it's what you want: scala> test("a", "b", "c") match { | case a if a.forall{_.isInstanceOf[String]} => a.map{ case s: String => s } | } res1: Array[String] = Array(a, b, c) In this case you don't need an Array: def method1(objs: Any*): Array[_] = objs match { case x if x.forall{_.isInstanceOf[MyClass1

Categories : Java

How do we layout Test Code with respect to Source Code
The question is a little imprecise - I'm assuming your question refers to unit testing code, and not acceptance tests, performance tests etc. The first thing to consider is that there is a tight coupling between test code and the code under test. You need to manage that dependency; how you manage it depends largely on your development strategy. If you use branches to separate features or releases, I'd put the test code for that branch in the same branch - you can't expect it to work on code from another branch. Adding a separate branch for test code makes things more complex, without necessarily adding any benefit. Secondly - hopefully obviously - you need to manage the dependencies. Your test code depends on the code under test; the code under test should not depend on the test code. U

Categories : Testing

uncompress and read gzip file in scala
Here's my version: import java.io.BufferedReader import java.io.InputStreamReader import java.util.zip.GZIPInputStream import java.io.FileInputStream class BufferedReaderIterator(reader: BufferedReader) extends Iterator[String] { override def hasNext() = reader.ready override def next() = reader.readLine() } object GzFileIterator { def apply(file: java.io.File, encoding: String) = { new BufferedReaderIterator( new BufferedReader( new InputStreamReader( new GZIPInputStream( new FileInputStream(file)), encoding))) } } Then do: val iterator = GzFileIterator(new java.io.File("test.txt.gz"), "UTF-8") iterator.foreach(println)

Categories : Scala

How to read the source of DartVM?
Here's my take on it. Learning the structure and function from source code, just by reading a source code is hard, and takes time. If there were some design documents to guide you, that would be easier, but would still be hard. It would be better (in my experience... so perhaps this isn't a good stackoverflow question) to focus your efforts in doing something with the VM. Pick a specific bug or enhancement and try and implement it. You'll learn much more by actually trying to maintain the code rather than just reading it. I mentioned "in my experience". Like you, I'm primarily a Java / C# dev, and haven't really looked at C++ for 15 years. Back in the early days of the Dart VM, there was a bug that was preventing me from doing something specific (I don't remember what, now). I had

Categories : C++

GWT @source annoation how to read from war folder?
@Source reads from the classpath at compile time. If you want/need to load resources that you don't want compiled into your JS, then use ScriptInjector or similar (RequestBuilder+StyleInjector or just dynamically adding a LinkElement to the DOM). If you want the ease of use of, say, ImageResource or CssResource, you could hand-write implementations rather than rely on the GWT generator. For CssResource, you could also simply use a dummy CSS stylesheet declaring all your classes as @external (and then injecting the CSS using either StyleInjector or a dynamic LinkElement).

Categories : Gwt

Read and download a page's source as Unicode in Java
if I do this manually, I'd save the .txt file with Unicode encoding rather than the default ANSI Windows is giving you misleading terminology here. There is no such encoding as ‘Unicode’; Unicode is the character set which is encoded in different ways into bytes. The encoding that Windows calls ‘Unicode’ is actually UTF-16LE. This is a two-byte-per-code-unit encoding that is not ASCII compatible and is generally inconvenient; Web pages tend not to work well with it. (For what it's worth the ‘ANSI’ code page isn't anything to do with ANSI either. Plus ça change...) PrintWriter out = new PrintWriter(name + (fileNumber+i) + ".html"); This creates a file using the Java default encoding, which is likely the ANSI code page in your case. To specify a different encoding, use

Categories : Java

how can I read information of an unknown source (byte,string...)?
You can't. If you are just receiving a long list of bytes and have no idea what it means, the best you could possibly do is just write out the byte values in hex or decimal. You need to find out what the format of the output stream is to make any use of it.

Categories : Java

Use ReportingService API to read custom data source credentials
You will need to pull down the rdl content and parse it:( Embedded data source information is stored in the .rdl and not a shared data set item obtained via the api. Even then you can't retrieve data source passwords.

Categories : Api

Python webpage source read with special characters
Encoding is a PITA in Python3 for sure (and 2 in some cases as well). Try checking these links out, they might help you: Python - Encoding string - Swedish Letters Python3 - ascii/utf-8/iso-8859-1 can't decode byte 0xe5 (Swedish characters) http://docs.python.org/2/library/codecs.html Also it would be nice with the code for "So when I read the page content without specifying any encoding" My best guess is that your console doesn't use utf-8 (for instance, windows.. your # -*- coding: utf-8 -*- only tells Python what type of characters to find within the sourcecode, not the actual data the code is going to parse or analyze itself. For instance i write: # -*- coding: iso-8859-1 -*- import time # Här skriver jag ut tiden (Translation: Here, i print out the time) print(time.strftime('

Categories : Python

Web page already open (in source format); just need to read that text, using Selenium
You can get the Source of the page directly with Selenium: WebDriver.getPageSource(). But if you use view-source:url the browser will present you a html-page including the formatted source. Firefox e.g. is wrapping each line in a <span id="lineX"></span>. Instead of parsing this just use getPageSource without view-source. Please read carefully the documentation of getPageSource: Get the source of the last loaded page. If the page has been modified after loading (for example, by Javascript) there is no guarantee that the returned text is that of the modified page. Please consult the documentation of the particular driver being used to determine whether the returned text reflects the current state of the page or the text last sent by the web server. The page source returned

Categories : Python

Error Attempting to read from the source install database C:WindowsInstaller*.msi
That error means the MSI (or some previous version with the same ProductCode) was installed on the machine but the cache was destroyed. I've seen this when people msizap (or use the poorly named FixIt tool from Microsoft) to try and yank an MSI off the machine. If msizap was used, the safest thing for testing purposes is to format the machine and start over. If formatting the machine is not possible (or msizap was not used) then try recache/reinstalling the new MSI to try and get the source cache patched up. You can do this using the command-line: msiexec /i new.msi /l*v log.txt That will cause the new.msi to be cached where the old MSI should have been then repair the machine trying to get it into a consistent state.

Categories : Dotnet



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.