I'm trying to learn more about how Lexical Analyzers/Parsers work. I haven't coded any classes yet, because i'm not really sure how the entire process from a Lexer to working code goes.
My goal is to write a simple made up programming language and translate that to another language, like Javascript. The first thing i have to do is give the code to a Lexical Analyzer.
The lexer will split the source into tokens and assign a label to it. So suppose i have the following code:
That's basically as far as i understand what a lexer does. How can i translate the tokens to a language like Javascript? From what i understand i need to write a Parser class. But i couldn't find any info on what that class exactly does. So what is exactly the next step i have to take?
I am creating an application which will work as a static code analyzer after compiling my code in VS 2008 for VC++ projects. It will be a kind of code review.
how and where do I need to put my custom rule sets, and what should I do to create such a application.
I am writing a simple file/text parser to read a config file for some code I am working on. It's dead simple and not particularly smart but it should get the job done. The code reads a config file:
Here is where it gets wierd. You'll notice that there is an unused variable (filepath) in the config struct. This variable is not referenced or used anywhere in the code, ever. Yet if I comment out the declaration of char filepath[1024], the code segfaults partway through the read_config() function.
My best guess is that there is a buffer overflow elsewhere and it just so happens that the memory allocated for filepath happened to be there to catch it up until now, but I can't work out where it might be happening. With the declaration commented out, the read_config() function gets as far as reading the "padding" variable before it crashes. Yet when the declaration is there, then all the variabled are read correctly and everything seems to work.
I have a 32-bit application that I've been maintaining for about 12 years and it runs on every Windows platform up to Windows 7. In all that time I've been using CWinApp::GetProfileXxxx() and CWinApp::WriteProfileXxxx() calls to read and write my program settings (about 70 settings) in the Registry. The settings are read from the Registry at start-up and written to the Registry when the program closes. There is also a method for the user to read and write the program settings to an INI file using the same code as the Registry access.
On my Windows 7 system the Registry read/write works just like it always has on all previous Windows versions. However, on some customer's Windows 7 machines there appears to be a problem with the Registry access. The program settings are either not being read from the Registry or are not being written to the Registry. I think the settings are not being written - but I don't know that. When the user uses the INI file the settings appear to be read and written.
The customer has complained a bit (I'd complain too) but doesn't have the time or doesn't want to take the time to run some simple tests for me to find out what's going on with his Windows 7 system.
So here is my question: Are there any user account settings or permissions that can block the program's access to the Registry? He claims he is an Administrator but I can't even get him to verify that.
I need to compute some values, place them in a structure containing two vector variables, and save them in a CSV file. Right now, I can't even generate a file. I wrote the structure definition and file writing code in a header file (after first borrowing it). I have a "button" that is supposed to trigger all of the activity. I'll attach the code below:
When I write to the Windows 7 Registry at HKEY_LOCAL_MACHINE, I get a return code of 5 which is the "access denied" message when I execute RegCreateKeyEx.
This happens even if the User has administrator rights.
How can I tell Windows 7 to allow the program to write to the registry?
The application is a 32-bit application and it should be allowed to run in either a Windows 7 32-bit or 64-bit machine.
I noticed that when I run certain popular programs, a User Account Control dialog box comes asking:
"Do if you want to allow the following program from an unknown publisher to make changes to this computer".
Should my application call User Account Control and if so, how do I do it in C++ Visual Studio 2008?
I also found out that 64-bit Windows machines have two registry hives. Is there a different code to handle the same task?
I just got a job programming a windows application. One of the requirements is reading and writing values from an excel spreadsheet. Looking online, it appears that C++ isn't the best (one of the worst?) languages for reading and writing values from excel files. Now the language I'm most familiar with is C++ and I've been looking at C#, and it appears to be much easier to read excel files.
I have to write a function called sortMe that sorts the elements of an array in numerical order from highest to lowest values (descending order) or vice versa (ascending order).
The assignment asks to: NOT re-arrange elements in the array; instead, it uses a second array, an array of indexes for the elements in the original array and then sortMe sorts the second array based on the values in the original array. A sorted version of the original array can then be produced with these sorted indexes.
Header of the function sortMe must be as shown below:
void sortMe(int array[],int sortedIndexes [], int size, char mode)
When mode is 'a', the function sorts the array in the ascending order, and when mode is 'd', the function sorts it in the descending order.
Declare and initialize the array array.
Declare the array sortedIndexes but do not initialize it. You are going to play with the array sortedIndexes in the function sortMe.
EXAMPLE:
int array[5]={3, 5,-1,10,0}; int sortedIndexes[5]; sortMe(array,sortedIndexes, 5, 'a');
After the function call, the elements of the array sortedIndexes should be: 2,4,0,1,3.
notice that the function does not e-arrange the elements in the array.
#include <stdio.h> #include <tchar.h> #include <iostream> #include <string> #include <fstream>// enable writing to and reading from files #include <cstdlib> #include <time.h> using namespace std; class Person {
[Code] .....
Error list:
Code:
Error 1 error LNK2019: unresolved external symbol "void __cdecl saveperson(void)" (?saveperson@@YAXXZ) referenced in function _main H:Cry_DevProgrammingC++Using_class_ in_ c++Using_class_ in_ c++Using_class_ in_ c++.obj Error 2 error LNK2019: unresolved external symbol "void __cdecl displayperson(void)" (?displayperson@@YAXXZ) referenced in function _main H:Cry_DevProgrammingC++Using_class_ in_ c++Using_class_ in_ c++Using_class_ in_ c++.obj Error 3 error LNK2019: unresolved external symbol "void __cdecl editperson(void)" (?editperson@@YAXXZ) referenced in function _main H:Cry_DevProgrammingC++Using_class_ in_ c++Using_class_ in_ c++Using_class_ in_ c++.obj Error 4 error LNK1120: 3 unresolved externals H:Cry_DevProgrammingC++Using_class_ in_ c++DebugUsing_class_ in_ c++.exe 1
I am writing a simple file parser for use in another project (for config file). The trickiest thing seems to be skipping unwanted characters (comments, spaces). It works partly, but after the second line of an inputed file processes only the first three characters.
I am implementing a recursive descent parser that recognizes strings in the language below.
The grammar: A -> I = E | E E -> T + E | T - E | T T -> F * T | F / T | F F -> P ^ F | P P -> I | L | UI | UL | (A) U -> + | - | ! I -> C | CI C -> a | b | ... | y | z L -> D | DL D -> 0 | 1 | ... | 8 | 9
My input file has the following two strings: a=a+b-c*d a=a**b++c
The desired output:
String read from file: a=a+b-c*d The string "a=a+b-c*d" is in the language. String read from file: a=a**b++c The string "a=a**b++c" is not in the language.
[Code].....
When I test the code without reading the text file and just write a string in the source code, it appears to parse fine. I believe my main problem is in the int main function and how i am reading the text file and outputting it. I was able to write the same program fine in Java.
since I didn't know how to type epsilon symbol temporarily I am using ^
char prod[20][20],T[20],NT[20],c[10][10],foll[10][10],fir[10][10]; int tt,tnt,tp,a; int follow[20][20],first[20][20]; void first_of(char); int count(int j); void rhs(int j);
I am trying to write a program that reads in an XML file, parses it and prints out information about each tag. I am getting the following errors when trying to build the program:
Parser.cpp:24:1: error: 'Parser' does not name a type Parser::getXMLData() { ^ Parser.cpp:120:1: error: 'Parser' does not name a type Parser:rocessXMLData(
I am using visual studio 2012.....in below code i m writing data in to a test.txt file but i dont know with which key file stop accepting char...i tried ctrl+z and ctrl+d but not working ....
I'm trying to write to a named pipe created by a service, as we all know the session 0 isolation implemented in vista and forward makes this task a bit complicated.
well at this point i managed to make almost all to work but my real problem comes when i try to write on the named pipe from my GUI application with no administrator rights
If i run the GUI application with admin rights it works 100% but, I don't need that application to require the user admin rights and for security reasons i rather to leave it without admin...
so i started my research and i found that there is a way to achieve this by calling CreateNamedPipe() with a low integrity security attributes...
well how to implement but i finally made it, the problem is that it gets worse than passing null security attributes, it works with admin rights with NULL security attributes, but when i pass the low integrity security attributes it gives "access denied" even when using admin rights, so i guess im passing the wrong security attributes but how to manually create the security descriptor string.
I would like to make a sort of text parser, in which one enters a string, and it is broken by the whitespaces into chunks, and those chunks compared to different "dictionaries" where the words are assigned a value. For example if the operator enters "take lamp" it would separate "take" and "lamp" and then produce preassigned values for each of these words.
I've knocked up a rough C parser for the purpose of colourizing code into XHTML/CSS, which makes me feel fancy. However, it doesn't quite handle comments properly. I can't quite work out how to deal with the slashes. Plus I'm sure there are other places that it slips up that don't feature in my simple tests, so here you go:-
For some reason when i put cout<<endl i'm getting segmentation faults in my Parser code. It's really weird some inputs of strings using cout is already faulting. However sometimes printf doesn't fault, but sometimes it will, it seems really unstable.
The court can basically be anywhere in the Parse(string) function, i have a cout at line 254 which faults.
So. I have a CSV Parser that I built. It works very well. The way it currently works is that I have the parser in a header file "CSV_Parser". So my .cpp code would look like this:
#include <iostream> #include <eigen3/Eigen/Dense> #include "CSV_Parser.h" using namespace std; using Eigen;
[Code] ....
This all works great. I am running Eclipse in Linux (Xubuntu to be precise). In the header file the .csv is opened as follows:
What I would like is for the user to be able to change the file that the parser is opening through the main .cpp file. In other words, is there a way to create some variable, say "FileName" and do the following:
I have written this code for predictive parser. It is working for valid input but it is not working for invalid input when i give invalid input it says its valid. How to do error handling in predictive parser.