Search Results

Search found 2937 results on 118 pages for 'recursive descent parser'.

Page 11/118 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Calculation Expression Parser with Nesting and Variables in ActionScript

    - by yuletide
    Hi There, I'm trying to enable dynamic fields in the configuration file for my mapping app, but I can't figure out how to parse the "equation" passed in by the user, at least not without writing a whole parser from scratch! I'm sure there is some easier way to do this, and so I'm asking for ideas! Basic idea: public var testString:String = "(#TOTPOP_CY#-#HISPOP_CY#)/#TOTPOP_CY#"; public var valueObject:Object = {TOTPOP_CY:1000, HISPOP_CY:100}; public function calcParse(eq:String):String { // do calculations return calculatedValue } So far, I was thinking of splitting the expression by either the operators, or maybe the variable tokens, but that gets rid of the parenthetical nesting. Alternatively, use a series of regex to search and replace each piece of the expression with its value, recursively running until only a number is left. But I don't think regex does math (i.e. replace "\d + \d" with the sum of the two numbers) Ideally, I'd just do a find/replace all variable names with their values, then run an eval(), but there's no eval in AS... eesh I downloaded some course materials for a course on compiler design, so maybe I'll just write a full-fledged calculator language and parser and port it over from the OTHER flex (the parser generator) :-D

    Read the article

  • Boost Binary Endian parser not working?

    - by Hai
    I am studying how to use boost spirit Qi binary endian parser. I write a small test parser program according to here and basics examples, but it doesn't work proper. It gave me the msg:"Error:no match". Here is my code. #include "boost/spirit/include/qi.hpp" #include "boost/spirit/include/phoenix_core.hpp" #include "boost/spirit/include/phoenix_operator.hpp" #include "boost/spirit/include/qi_binary.hpp" // parsing binary data in various endianness template '<'typename P, typename T void binary_parser( char const* input, P const& endian_word_type, T& voxel, bool full_match = true) { using boost::spirit::qi::parse; char const* f(input); char const* l(f + strlen(f)); bool result1 = parse(f,l,endian_word_type,voxel); bool result2 =((!full_match) || (f ==l)); if ( result1 && result2) { //doing nothing, parsing data is pass to voxel alreay } else { std::cerr << "Error: not match!!" << std::endl; exit(1); } } typedef boost::uint16_t bs_int16; typedef boost::uint32_t bs_int32; int main ( int argc, char *argv[] ) { namespace qi = boost::spirit::qi; namespace ascii = boost::spirit::ascii; using qi::big_word; using qi::big_dword; boost::uint32_t ui; float uf; binary_parser("\x01\x02\x03\x04",big_word,ui); assert(ui=0x01020304); binary_parser("\x01\x02\x03\x04",big_word,uf); assert(uf=0x01020304); return 0; }' I almost copy the example, but why this binary parser doesn't work. I use Mac OS 10.5.8 and gcc 4.01 compiler.

    Read the article

  • Spring.net customer namespace parser

    - by ListenToRick
    I have a customer parser which looks like this: [NamespaceParser( Namespace = "http://mysite/schema/cache", SchemaLocationAssemblyHint = typeof(CacheNamespaceParser ), SchemaLocation = "/cache.xsd" ) ] public class CacheNamespaceParser : NamespaceParserSupport { public override void Init() { RegisterObjectDefinitionParser("cache", new CacheParser ()); } } public class CacheParser : AbstractSimpleObjectDefinitionParser { protected override Type GetObjectType(XmlElement element) { return typeof(CacheDefinition); } protected override void DoParse(XmlElement element, ObjectDefinitionBuilder builder) { } protected override bool ShouldGenerateIdAsFallback { get { return true; } } } in the web config i have the following configuration.... <spring> <parsers> <parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data"/> <parser type="App.Web.CacheNamespaceParser, WebApp" /> </parsers> When I run the project I get the following error: An error occurred creating the configuration section handler for spring/parsers: Invalid resource name. Name has to be in 'assembly:<assemblyName>/<namespace>/<resourceName>' format. I put a break point in the CacheNamespaceParser init method and it is called. If I remove from the web config all is well! Any ideas whats wrong

    Read the article

  • Parser Error Problem

    - by user177140
    Hi I have found a problem in Multilingual Asp.Net Web Application I have Created a Global.asax file and write the code private void Application_BeginRequest(Object source, EventArgs e) { string[] languages = HttpContext.Current.Request.UserLanguages; if (languages[0].ToLower() != null && languages[0].ToLower()!="") { System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(languages[0].ToLower()); System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(languages[0].ToLower()); } } and define Label Like this <asp:Label ID="Labeldg" runat="server" Text="<%$ Resources:Resource, Labeldg %>"</asp:Label> But it through Parser error like: Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: The resource object with key 'LblUsrName_Login' was not found. Source Error: </div> <div class="impcLoginText_Login"> <asp:Label ID="LblUsrName" runat="server" Text="<%$ Resources:PageResource, LblUsrName_Login %>" "></asp:Label>

    Read the article

  • Beautifulsoup recursive attribute

    - by Marcos Placona
    Hi, trying to parse an XML with Beautifulsoup, but hit a brick wall when trying to use the "recursive" attribute with findall() I have a pretty odd xml format shown below: <?xml version="1.0"?> <catalog> <book id="bk101"> <author>Gambardella, Matthew</author> <title>XML Developer's Guide</title> <genre>Computer</genre> <price>44.95</price> <publish_date>2000-10-01</publish_date> <description>An in-depth look at creating applications with XML.</description> <catalog>true</catalog> </book> <book id="bk102"> <author>Ralls, Kim</author> <title>Midnight Rain</title> <genre>Fantasy</genre> <price>5.95</price> <publish_date>2000-12-16</publish_date> <description>A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.</description> <catalog>false</catalog> </book> </catalog> As you can see, the catalog tag repeats inside the book tag, which causes an error when I try to to something like: from BeautifulSoup import BeautifulStoneSoup as BSS catalog = "catalog.xml" def open_rss(): f = open(catalog, 'r') return f.read() def rss_parser(): rss_contents = open_rss() soup = BSS(rss_contents) items = soup.findAll('catalog', recursive=False) for item in items: print item.title.string rss_parser() As you will see, on my soup.findAll I've added recursive=false, which in theory would make it no recurse through the item found, but skip to the next one. This doesn't seem to work, as I always get the following error: File "catalog.py", line 17, in rss_parser print item.title.string AttributeError: 'NoneType' object has no attribute 'string' I'm sure I'm doing something stupid here, and would appreciate if someone could give me some help on how to solve this problem. Changing the HTML structure is not an option, this this code needs to perform well as it will potentially parse a large XML file. Thanks in advance, Marcos

    Read the article

  • Ordering recursive result set in SQL Server

    - by Ben
    I am having extreme difficulty constructing a query which returns an XML style hierarchy. We have a database table which contains a hierarchy of URLs for our website. The table contains the columns: ID, URL, DisplayName, ParentID, ItemOrder The parent ID forms a recursive relationship between the current item and it's parent. The item should site below it's parent in the hierarchy and it should also be ordered using the item order against items at the same level in the hierarchy. I have managed to get a recursive query working so it drills down the hierarchy sequentially but I cannot order this by the item order as well. My current query is below: WITH Parents AS ( SELECT MenuItemId, URL, ParentItemId, ItemOrder FROM CambsMenu UNION ALL SELECT si.MenuItemId, si.URL, si.ParentItemId, si.ItemOrder FROM CambsMenu si INNER JOIN Parents p ON si.ParentItemId = p.MenuItemId ) SELECT DISTINCT * FROM Parents

    Read the article

  • recursive program

    - by wilson88
    I am trying to make a recursive program that calculates interest per year.It prompts the user for the startup amount (1000), the interest rate (10%)and number of years(1).(in brackets are samples) Manually I realised that the interest comes from the formula YT(1 + R)----- interest for the first year which is 1100. 2nd year YT(1 + R/2 + R2/2) //R squared 2nd year YT(1 + R/3 + R2/3 + 3R3/) // R cubed How do I write a recursive program that will calculate the interest? Below is the function which I tried double calculateInterest(double startUp, double rate, double duration) { double cpdInterest = (duration*startUp)*(1 + rate); if (duration == 0) { return cpdInterest; } else if (duration < 0) { cout << "Please enter a valid year"; } else { calculateInterest(cpdInterest,rate,duration); } return cpdInterest; }

    Read the article

  • Time Complexities of recursive algorithms

    - by Peter
    Whenever I see a recursive solution, or I write recursive code for a problem, it is really difficult for me to figure out the time complexity, in most of the cases I just say its exponential? How is it exponential actually? How people say it is 2^n, when it is n!, when it is n^n or n^k. I have some questions in mind, let say find all permutations of a string (O(n!)) find all sequences which sum up to k in an array (exponential, how exactly do I calculate). Find all subsets of size k whose sum is 0 (will k come somewhere in complexity , it should come right?). Can any1 help me how to calculate the exact complexity of such questions, I am able to wrote code for them , but its hard understanding the exact time complexity.

    Read the article

  • recursive program

    - by wilson88
    I am trying to make a recursive program that calculates interest per year.It prompts the user for the startup amount (1000), the interest rate (10%)and number of years(1).(in brackets are samples) Manually I realised that the interest comes from the formula YT(1 + R)----- interest for the first year which is 1100. 2nd year YT(1 + R/2 + R2/2) //R squared 2nd year YT(1 + R/3 + R2/3 + 3R3/) // R cubed How do I write a recursive program that will calculate the interest? Below is the function which I tried //Latest after editing double calculateInterest2(double start, double rate, int duration) { if (0 == duration) { return start; } else { return (1+rate) * calculateInterest2(start, rate, duration - 1); } }

    Read the article

  • Recursive Functions for Beginners?

    - by cam
    I'm looking for a few recursive function examples, preferably ones that show increase in complexity. I understand basic recursive functions, but I'm having trouble implementing them in my code. I've never used them in my code before, and I know it doesn't always call for it, but I'd like to try. Is there a good resource with examples, and maybe challenges of some sort? Or even some simple math problems (Project Euler-style?) that I could use recursion on? For examples, I prefer C#, but anything works.

    Read the article

  • Get recursive data with sql server

    - by user228777
    I am trying to get recursive data. Following code returns all parents on the top and then the children. I would like to get data Parent 1 – his children then parent 2 - his children then parent3 – his children. How do I do this? USE Subscriber GO WITH Parent (ParentId, Id, Name,subscriberID) AS ( -- Anchor member definition SELECT A.ParentId,A.id, A.name,A.SubscriberId FROM Subscriber.Budget.SubscriberCategory AS A WHERE ParentId IS NULL UNION ALL -- Recursive member definition SELECT B.ParentId, B.id, B.name,B.SubscriberId FROM Subscriber.Budget.SubscriberCategory AS B INNER JOIN Parent AS P ON B.ParentId = P.Id ) -- Statement that executes the CTE SELECT parentId, id, name FROM Parent where subscriberID = '1C18093B-5031-42E4-9251-CEF69114365F' GO

    Read the article

  • What does this recursive function do?

    - by null
    What does this function do? And how do you evaluate it? How to trace it? How to understand recursive method? I just can't understand the recursion, and the exam date is coming soon, and I know in order to understand recursion, I must first understand recursion. But I just can't write a slightly complex recursive method, can anyone help me out using the simplest English words. public class BalancedStrings { public static void printBalanced(String prefix, int a, int b) { if (a > 0) printBalanced(prefix + "a", a - 1, b); if (b > 0) printBalanced(prefix + "b", a, b - 1); if (a == 0 && b == 0) System.out.println(prefix); } public static void printBalanced(int n) { if (n % 2 == 0) { printBalanced("", n / 2, n / 2); } } public static void main(String[] args) { printBalanced(4); } }

    Read the article

  • Parser Error Message: Could not load type 'TestMvcApplication.MvcApplication'

    - by Riaan Engelbrecht
    I am getting the following error on one of our production servers. Not sure why it is working on the DEV server? Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: Could not load type 'TestMvcApplication.MvcApplication'. Source Error: Line 1: <%@ Application Codebehind="Global.asax.cs" Inherits="TestMvcApplication.MvcApplication" Language="C#" % Source File: /global.asax Line: 1 Not sure if anybody came across this error before and how it was solved, but I have reached the end. Any help would be appreciated. I also need to mention that this is the published code, so all is compiled. Can there be something wrong with my compiler settings?

    Read the article

  • Mibble MIB Parser - extracting comments from the mib.

    - by this.matt
    I am using the Mibble MIB Parser to extract all simple data types from an MIB file. I've been successful until my attempt to extract comment text. Take the following module as an example: invBookList OBJECT-TYPE SYNTAX INTEGER { mobydick(1), -- call me ishmael paradiselost(2), -- aComment 1984(3), -- aComment solaris(4) -- aComment } MAX-ACCESS read-only STATUS current DESCRIPTION "A few Books for an example." ::= { invMasterList 43 } According to Mibble's API, the OBJECT-TYPE can be accessed by extracting an SnmpObjectType and then calling the appropriate getter method. Which I have done, and can successfully extract all of the text except the comments in the INTEGER syntax. I have tried calling getSyntax().getComment() on the SnmpObjectType, but always returns null. getSyntax() will extract the INTEGER syntax, e.g.: mobydick(1),paradiselist(2),1984(3),solaris(4) but unfortunately strips out the comments. Any one out there have experience with Mibble Parser who knows how to extract the comments? Many Thanks.

    Read the article

  • Is there a tool for generating a DSL parser that does not require a runtime for the resultant parser

    - by Chris
    I'm doing a lot of work with a DSLs at the moment and was wondering if anyone knew of a tool that could generate a parser for my bnf specification that does not require a run-time library (pure java source parser)? I'm committed to using XTEXT for a future Eclipse plug-in but I need a nice small version for my library itself and don't want to add another jar dependency. It seems that ANTLR requires a run-time to parse files and I performed a Google search with no avail. Can anyone help out? Thanks, Chris

    Read the article

  • Looking for a php template Parser with nesting

    - by christian
    Hi Iam looking for a php parser that can do this. {tag} Replace the tag with text comming from a function {tag(params)} It must support params {tag({tag(params)},{tag(params)})} It must support nesting {tag()? else } It must support Tests {$tag=value} It must support varriables Do anyone of you know of an parser that can do this? Or maby you know how i can create one. I have tryed to do this with preg, but it seems impossible to create nesting. Smarty seems to be a bit to big, and i dont know if you can disable all the extra functionality it has. I only need the functionality that i have listet over. In smarty your able to write php code and i dont like that. {php} {/php} So if iam going to use that i need to be able to turn it of. (Iam going to use it with codeigniter.)

    Read the article

  • What is a good Javascript RDFa parser implementation?

    - by tremoloqui
    I am looking to implement a client side RDFa based formatting for a web application. This would be similar to Mark Birbeck's ubiquity-rdfa project. Mark's project looks fantastic but it has at least two drawbacks: It is slow. Adding RDFa formatting to a simple page causes a noticeable delay in page loading. It is complex. The ubiquity-rdfa project makes use of the w3c fresnel specification which is complex way to add simple annotations to client markup. I am looking for a lighter weight way of adding annotations through client code and I don't mind doing some work to get it. What I would like is a fast and reliable Javascript RDFa parser. Some implementations that I have found include: W3C RDFa bookmarklet parser Elias Torres RDFa extractor I am interested to know if you would recommend one of these, or another, RDFa Javascript implementation. Thanks!

    Read the article

  • ICalendar parser in PHP that supports timezones

    - by Vincent Robert
    I am looking for a PHP class that can parse an ICalendar (ICS) file and correctly handle timezones. I already created an ICS parser myself but it can only handle timezones known to PHP (like 'Europe/Paris'). Unfortunately, ICS file generated by Evolution (default calendar software of Ubuntu) does not use default timezone IDs. It exports events with its a specific timezone ID exporting also the full definition of the timezone: daylight saving dates, recurrence rule and all the hard stuff to understand about timezones. This is too much for me. Since it was only a small utility for my girlfriend, I won't have time to investigate further the ICalendar specification and create a full blown ICalendar parser myself. So is there any known implementation in PHP of ICalendar file format that can parse timezones definitions?

    Read the article

  • Parser line break if string contains &#8211;

    - by pask
    Hi all, My NSXMLParser breaks on this string: <title>AAA &#8211; BCDEFGQWERTYUIO</title> I parsed it in this way, hope is the right way: - (void) parser: (NSXMLParser *) parser foundCharacters: (NSString *) string{ [...] if ([currentElement isEqualToString:@"title"]) { if (![string isEqualToString:@""]) { [title addObject:string]; NSLog(@"str: %@", string); } } it returns me: str: AAA str: - str: BCDEFGQWERTYUIO But i want to return a single string: str: AAA - BCDEFGQWERTYUIO because it's the correct title. Any idea? Thanks.

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >