Programming :: Removing Left Recursion - Construct An AST From It By Executing A Piece Of Code For Every Nonterminal Matched?
Apr 7, 2011
I'm still a but confused about the standard way of removing it for left-associative operators: [URL] Especially about how to construct an AST from it by executing a peice of code for every nonterminal matched. And I'm still not totally convinced that it will be left-associative, I just barely understand it. Also, how would you remove left-recursion for something like this:
expr ::= expr "(" param_list ")"
| other stuff...?
The first is about implementing function calls. The way I currently have it is that functions are called with a C++ std::vector of nodes as the parameters. How would I turn a comma-seperated list of expressions into a C++ vector in the grammar?Second, how do you implement left-associative operators in a parser that does not allow left recursion?
And third, what would be the best internal representation of integers? A C++ int seems simplest, but limited. Using GMP seems more versatile, but I'm afraid it might seriously slow down the interpreter compared to C++ ints.
Can someone recommend piece parts construct a reliable green server?
I am thinking: -Case with hot swapable drives, and energy efficient power supply -SSD harddrive for 5900 RPM drive -low power CPU, but one with a decent amount of power, IE. 2.0ghz dual core or better.
I have an application, probably cpu-intensive because sometimes it leaves the cpu with 0% idle (in top). Sometimes it hangs ("Done" does not print) when executing this part, but most of the time it executes just fine. Is there any wrong with this code?
So, I usually write/find a test case generator for any code that I write. This type of code generally leads to some file output. To be thorough, I try and generate many different files to test my code on.
Say the command is like this:
Is there a way to automate this for many different values of the parameters and generate many different files?
I wasn't able to use the $i in the filename, and without it the command gave me no errors, but did nothing else either. I know the Unix command line is very powerful, and I have a feeling that this should be possible, but I just don't know how to do it.
I am trying to construct a quick regex that will search for six lines of text without a clear line break between them. It only needs to search, not replace, as I will be using in gEdit (with regex plugin) anyway.
It's for editing subtitle files. The video player I will be using them on can only cope with 3-line subtitles, so I just need to edit any in the srt file that contain four or more. There won't be many so I can do it manually. For example:
26 00:01:47,357 --> 00:01:49,359 a motivated business professional with clearly defined goals.
but .* seems to mean "any character, or none", so that doesn't work. My experience of regular expressions is limited, but I do know they are very powerful when used correctly!
i have installed bless hex editor on my fedora 14 laptop.However when i open it ,it shows "mono-core wants to install a font language code not matched: utf-8" i am not able to use bless hex editor properly.
build a Linux environment in which only "signed" processes are allowed to run. When I say signed I don't mean a VeriSign etc. signature like you know it from Windows, but I mean signed by myself. I.e. I choose the software allowed to run, sign it, and then want to deny any other processes to run.If it is somehow possible I'd like to extend this even to scripts and the kernel (i.e. no unsigned modules can be loaded).Does anyone have a good idea how to solve this problem?The bad thing is: I'm pretty fine with coding stuff myself in C, but have absolutely 0 experience or knowledge in kernel (module)-programming.Any tipps, links, literatureOne approach I came up with (just a rough idea at the moment):Linux starts new processes with a fork-and-exec-combination. I therefore wonder if it is possible to change exec() in such a way that it will only execute signed programs
I remember reading that using sed, you can do this with parentheses: s/abc(something)def/(something)else/g I can't find an explanation of how to do something like this with Awk. Say you have this in an HTML file, where (number) stands for a one or two-digit number:
need to modify some scripts to repeat the commands in them until a variable returns a proper value. I need it to add some redundancy to some scripts i use to upload files to a remote server.This is an example of a portion of those scripts:
Slipping some (non-root) user a piece of malignant code that he or she executes might be considered as one of the highest security breaches possible. (The only higher I can see is actually accessing the root user) What can an attacker effectively do when he/she gets a standard, (let's say a normal Ubuntu user) to execute code? Where would an attacker go from there? What would that piece of code do?
Let's say that the user is not stupid enough to be lured into entering the root/sudo password into a form/program she doesn't know. Only software from trusted sources is installed. The way I see it there is not really much one could do, is there?
Addition: I partially ask this because I am thinking of granting some people shell (non-root) access to my server. They should be able to have normal access to programs. I want them to be able to compile programs with gcc. So there will definitely be arbitrary code run in user-space...
I am trying to find sed command combination to print out the "start command" line, the id line and all lines between "details" and "stop command" only if "error" exists. Here's the original output (test.txt):
what we are trying to do is, to let the customer click a button in the web browser, and then the web server to call a shell script to do the work. The output from the stdout && stderr of the script should be displayed in the web browser once finished or timeout, along with the exit code of the script.
The shell script is however not on the web server, but on another app server. So to call this script from the web server as the identity 'tomcat':
Code: $ sh appuser@app-server:$appbin/app-script
The .ssh/id_rsa.pub thing is done, and we have no problem doing this in the command line so far.
Our loaded ex-colleage has left us the webpages (jsp) with code like these:
Code: <%@ include file="jsp_functions.jsp" %> <% String cmd = "sh $appbin/app-script"; ExecResult r = new ExecResult();
I need a way to read and delete text found before a unique string, then delete the string. I would like to have the text stored in a variable--or better yet--executed it as a shell script directly.I intend to execute the stored text in bash. It does not matter much what language the program is it, however efficiency is desirable. This script is not going to be used on large files, but it may be executed many times sequentially so the faster the script works the better. Here is an example:
I need to execute an external command with Python from Web. I know there is subprocess module that executes external programs but I'm trying to execute a command registered for the execution of a program. In this case when I execute my file in the shell everything is Ok, but from the Web it doesn't work.
what i did is created a file called pro3types but the script starts & by pass the file. i added +x to file ran the process but still no luck. i was wondering what else i should change to get the menu to the sub-categories of product3 after users selecting it. all I need to get the pro3types runs after users selecting product3 from the previous menu. need more info please see the thread: "Adding New Selections to the existing Script"
I trying to write a UART(interfacing of serial devices) to linux machine but after I execute the following code to receive data I need to enter key (carriage return).... but I don't want to remove carriage return/enter key
I am fairly new to linux still and I'm currently trying to write a shell script (which I have never done) that is supposed to run the xrestop(like top) program. What I want to do is execute the program and check the identifier column to see if a certain program is running. If it is running I want to strip the data from that row of the terminal say every 5 seconds or so and put it in a text file. Is this going to be a complicated thing?
Heres a list of the columns when you run xrestop program res-base Wins GCs Fnts Pxms Misc PxmMem Other Total PID Identifier.
I am wanting to do some experimenting with some virtual machines as well as get to know some of the other distros out there.
I was just wondering if I were to construct a VM on VirtualBox, and then sometime down the road uninstall it when finished. What would be the best way to go about uninstalling as far as completely restoring the space and partition that was being used back to my main partition?
I have been searching for 90 minutes for something that I "think" should be fairly easy. I'm pretty new to Bash Scripting so I could be completely wrong. Then again it may be a weird request to even need something like this. But here it is.I have a script written to convert data from one of our software version to another. The only thing I need to add to it is a "check to make sure the user running the script is in the /tmp directory".