Search Results

Search found 33 results on 2 pages for 'bnf'.

Page 1/2 | 1 2  | Next Page >

  • BNF – how to read syntax?

    - by Piotr Rodak
    A few days ago I read post of Jen McCown (blog) about her idea of blogging about random articles from Books Online. I think this is a great idea, even if Jen says that it’s not exciting or sexy. I noticed that many of the questions that appear on forums and other media arise from pure fact that people asking questions didn’t bother to read and understand the manual – Books Online. Jen came up with a brilliant, concise acronym that describes very well the category of posts about Books Online – RTFM365. I take liberty of tagging this post with the same acronym. I often come across questions of type – ‘Hey, i am trying to create a table, but I am getting an error’. The error often says that the syntax is invalid. 1 CREATE TABLE dbo.Employees 2 (guid uniqueidentifier CONSTRAINT DEFAULT Guid_Default NEWSEQUENTIALID() ROWGUIDCOL, 3 Employee_Name varchar(60) 4 CONSTRAINT Guid_PK PRIMARY KEY (guid) ); 5 The answer is usually(1), ‘Ok, let me check it out.. Ah yes – you have to put name of the DEFAULT constraint before the type of constraint: 1 CREATE TABLE dbo.Employees 2 (guid uniqueidentifier CONSTRAINT Guid_Default DEFAULT NEWSEQUENTIALID() ROWGUIDCOL, 3 Employee_Name varchar(60) 4 CONSTRAINT Guid_PK PRIMARY KEY (guid) ); Why many people stumble on syntax errors? Is the syntax poorly documented? No, the issue is, that correct syntax of the CREATE TABLE statement is documented very well in Books Online and is.. intimidating. Many people can be taken aback by the rather complex block of code that describes all intricacies of the statement. However, I don’t know better way of defining syntax of the statement or command. The notation that is used to describe syntax in Books Online is a form of Backus-Naur notatiion, called BNF for short sometimes. This is a notation that was invented around 50 years ago, and some say that even earlier, around 400 BC – would you believe? Originally it was used to define syntax of, rather ancient now, ALGOL programming language (in 1950’s, not in ancient India). If you look closer at the definition of the BNF, it turns out that the principles of this syntax are pretty simple. Here are a few bullet points: italic_text is a placeholder for your identifier <italic_text_in_angle_brackets> is a definition which is described further. [everything in square brackets] is optional {everything in curly brackets} is obligatory everything | separated | by | operator is an alternative ::= “assigns” definition to an identifier Yes, it looks like these six simple points give you the key to understand even the most complicated syntax definitions in Books Online. Books Online contain an article about syntax conventions – have you ever read it? Let’s have a look at fragment of the CREATE TABLE statement: 1 CREATE TABLE 2 [ database_name . [ schema_name ] . | schema_name . ] table_name 3 ( { <column_definition> | <computed_column_definition> 4 | <column_set_definition> } 5 [ <table_constraint> ] [ ,...n ] ) 6 [ ON { partition_scheme_name ( partition_column_name ) | filegroup 7 | "default" } ] 8 [ { TEXTIMAGE_ON { filegroup | "default" } ] 9 [ FILESTREAM_ON { partition_scheme_name | filegroup 10 | "default" } ] 11 [ WITH ( <table_option> [ ,...n ] ) ] 12 [ ; ] Let’s look at line 2 of the above snippet: This line uses rules 3 and 5 from the list. So you know that you can create table which has specified one of the following. just name – table will be created in default user schema schema name and table name – table will be created in specified schema database name, schema name and table name – table will be created in specified database, in specified schema database name, .., table name – table will be created in specified database, in default schema of the user. Note that this single line of the notation describes each of the naming schemes in deterministic way. The ‘optionality’ of the schema_name element is nested within database_name.. section. You can use either database_name and optional schema name, or just schema name – this is specified by the pipe character ‘|’. The error that user gets with execution of the first script fragment in this post is as follows: Msg 156, Level 15, State 1, Line 2 Incorrect syntax near the keyword 'DEFAULT'. Ok, let’s have a look how to find out the correct syntax. Line number 3 of the BNF fragment above contains reference to <column_definition>. Since column_definition is in angle brackets, we know that this is a reference to notion described further in the code. And indeed, the very next fragment of BNF contains syntax of the column definition. 1 <column_definition> ::= 2 column_name <data_type> 3 [ FILESTREAM ] 4 [ COLLATE collation_name ] 5 [ NULL | NOT NULL ] 6 [ 7 [ CONSTRAINT constraint_name ] DEFAULT constant_expression ] 8 | [ IDENTITY [ ( seed ,increment ) ] [ NOT FOR REPLICATION ] 9 ] 10 [ ROWGUIDCOL ] [ <column_constraint> [ ...n ] ] 11 [ SPARSE ] Look at line 7 in the above fragment. It says, that the column can have a DEFAULT constraint which, if you want to name it, has to be prepended with [CONSTRAINT constraint_name] sequence. The name of the constraint is optional, but I strongly recommend you to make the effort of coming up with some meaningful name yourself. So the correct syntax of the CREATE TABLE statement from the beginning of the article is like this: 1 CREATE TABLE dbo.Employees 2 (guid uniqueidentifier CONSTRAINT Guid_Default DEFAULT NEWSEQUENTIALID() ROWGUIDCOL, 3 Employee_Name varchar(60) 4 CONSTRAINT Guid_PK PRIMARY KEY (guid) ); That is practically everything you should know about BNF. I encourage you to study the syntax definitions for various statements and commands in Books Online, you can find really interesting things hidden there. Technorati Tags: SQL Server,t-sql,BNF,syntax   (1) No, my answer usually is a question – ‘What error message? What does it say?’. You’d be surprised to know how many people think I can go through time and space and look at their screen at the moment they received the error.

    Read the article

  • Converting EBNF to BNF

    - by Vivin Paliath
    It's been a few years since my computer-language class and so I've forgotten the finer points of BNF's and EBNF's and I don't have a textbook next to me. Specifically, I've forgotten how to convert an EBNF into BNF. From what little I remember, I know that one of the main points is to convert { term } into <term> | <many-terms>. But I don't remember the other rules. I've tried to look this up online but I can only find links to either homework questions, or a small comment about converting terms with curly braces. I can't find an exhaustive list of rules that define the translation.

    Read the article

  • URL BNF search part does not make sense

    - by Asaf Mesika
    Hi, While implementing a Java regular expression for URL based on the URL BNF published by W3C, I've failed to understand the search part. As quoted: httpaddress h t t p : / / hostport [ / path ] [ ? search ] search xalphas [ + search ] xalphas xalpha [ xalphas ] xalpha alpha | digit | safe | extra | escape alpha a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | digit 0 |1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 safe $ | - | _ | @ | . | & | + | - extra ! | * | " | ' | ( | ) | , Search claims it is xalphas seperated by a plus sign. xalphas can contain plus signs by it self, as claimed by safe. Thus according to my understanding , it should be: search xalphas Where am I wrong here?

    Read the article

  • Is it easier to write a recursive-descent parser using an EBNF or a BNF?

    - by Vivin Paliath
    I've got a BNF and EBNF for a grammar. The BNF is obviously more verbose. I have a fairly good idea as far as using the BNF to build a recursive-descent parser; there are many resources for this. I am having trouble finding resources to convert an EBNF to a recursive-descent parser. Is this because it's more difficult? I recall from my CS theory classes that we went over EBNFs, but we didn't go over converting them into a recursive-descent parser. We did go over converting BNF's into a recursive-descent parser. The reason I'm asking is because the EBNF is more compact. From looking at the EBNF's in general, I notice that terms enclosed between { and } can be converted into a while loop. Are there any other guidelines or rules?

    Read the article

  • How to get SQL Railroad Diagrams from MSDN BNF syntax notation.

    - by Phil Factor
    pre {margin-bottom:.0001pt; font-size:8.0pt; font-family:"Courier New"; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm; } On SQL Server Books-On-Line, in the Transact-SQL Reference (database Engine), every SQL Statement has its syntax represented in  ‘Backus–Naur Form’ notation (BNF)  syntax. For a programmer in a hurry, this should be ideal because It is the only quick way to understand and appreciate all the permutations of the syntax. It is a great feature once you get your eye in. It isn’t the only way to get the information;  You can, of course, reverse-engineer an understanding of the syntax from the examples, but your understanding won’t be complete, and you’ll have wasted time doing it. BNF is a good start in representing the syntax:  Oracle and SQLite go one step further, and have proper railroad diagrams for their syntax, which is a far more accessible way of doing it. There are three problems with the BNF on MSDN. Firstly, it is isn’t a standard version of  BNF, but an ancient fork from EBNF, inherited from Sybase. Secondly, it is excruciatingly difficult to understand, and thirdly it has a number of syntactic and semantic errors. The page describing DML triggers, for example, currently has the absurd BNF error that makes it state that all statements in the body of the trigger must be separated by commas.  There are a few other detail problems too. Here is the offending syntax for a DML trigger, pasted from MSDN. Trigger on an INSERT, UPDATE, or DELETE statement to a table or view (DML Trigger) CREATE TRIGGER [ schema_name . ]trigger_name ON { table | view } [ WITH <dml_trigger_option> [ ,...n ] ] { FOR | AFTER | INSTEAD OF } { [ INSERT ] [ , ] [ UPDATE ] [ , ] [ DELETE ] } [ NOT FOR REPLICATION ] AS { sql_statement [ ; ] [ ,...n ] | EXTERNAL NAME <method specifier [ ; ] > }   <dml_trigger_option> ::=     [ ENCRYPTION ]     [ EXECUTE AS Clause ]   <method_specifier> ::=  This should, of course, be /* Trigger on an INSERT, UPDATE, or DELETE statement to a table or view (DML Trigger) */ CREATE TRIGGER [ schema_name . ]trigger_name ON { table | view } [ WITH <dml_trigger_option> [ ,...n ] ] { FOR | AFTER | INSTEAD OF } { [ INSERT ] [ , ] [ UPDATE ] [ , ] [ DELETE ] } [ NOT FOR REPLICATION ] AS { {sql_statement [ ; ]} [ ...n ] | EXTERNAL NAME <method_specifier> [ ; ] }   <dml_trigger_option> ::=     [ ENCRYPTION ]     [ EXECUTE AS CLAUSE ]   <method_specifier> ::=     assembly_name.class_name.method_name I’d love to tell Microsoft when I spot errors like this so they can correct them but I can’t. Obviously, there is a mechanism on MSDN to get errors corrected by using comments, but that doesn’t work for me (*Error occurred while saving your data.”), and when I report that the comment system doesn’t work to MSDN, I get no reply. I’ve been trying to create railroad diagrams for all the important SQL Server SQL statements, as good as you’d find for Oracle, and have so far published the CREATE TABLE and ALTER TABLE railroad diagrams based on the BNF. Although I’ve been aware of them, I’ve never realised until recently how many errors there are. Then, Colin Daley created a translator for the SQL Server dialect of  BNF which outputs standard EBNF notation used by the W3C. The example MSDN BNF for the trigger would be rendered as … /* Trigger on an INSERT, UPDATE, or DELETE statement to a table or view (DML Trigger) */ create_trigger ::= 'CREATE TRIGGER' ( schema_name '.' ) ? trigger_name 'ON' ( table | view ) ( 'WITH' dml_trigger_option ( ',' dml_trigger_option ) * ) ? ( 'FOR' | 'AFTER' | 'INSTEAD OF' ) ( ( 'INSERT' ) ? ( ',' ) ? ( 'UPDATE' ) ? ( ',' ) ? ( 'DELETE' ) ? ) ( 'NOT FOR REPLICATION' ) ? 'AS' ( ( sql_statement ( ';' ) ? ) + | 'EXTERNAL NAME' method_specifier ( ';' ) ? )   dml_trigger_option ::= ( 'ENCRYPTION' ) ? ( 'EXECUTE AS CLAUSE' ) ?   method_specifier ::= assembly_name '.' class_name '.' method_name Colin’s intention was to allow anyone to paste SQL Server’s BNF notation into his website-based parser, and from this generate classic railroad diagrams via Gunther Rademacher's Railroad Diagram Generator.  Colin's application does this for you: you're not aware that you are moving to a different site.  Because Colin's 'translator' it is a parser, it will pick up syntax errors. Once you’ve fixed the syntax errors, you will get the syntax in the form of a human-readable railroad diagram and, in this form, the semantic mistakes become flamingly obvious. Gunter’s Railroad Diagram Generator is brilliant. To be able, after correcting the MSDN dialect of BNF, to generate a standard EBNF, and from thence to create railroad diagrams for SQL Server’s syntax that are as good as Oracle’s, is a great boon, and many thanks to Colin for the idea. Here is the result of the W3C EBNF from Colin’s application then being run through the Railroad diagram generator. create_trigger: dml_trigger_option: method_specifier:   Now that’s much better, you’ll agree. This is pretty easy to understand, and at this point any error is immediately obvious. This should be seriously useful, and it is to me. However  there is that snag. The BNF is generally incorrect, and you can’t expect the average visitor to mess about with it. The answer is, of course, to correct the BNF on MSDN and maybe even add railroad diagrams for the syntax. Stop giggling! I agree it won’t happen. In the meantime, we need to collaboratively store and publish these corrected syntaxes ourselves as we do them. How? GitHub?  SQL Server Central?  Simple-Talk? What should those of us who use the system  do with our corrected EBNF so that anyone can use them without hassle?

    Read the article

  • Metalanguage like BNF or XML-Schema to validate a tree-instance against a tree-model

    - by Stefan
    Hi! I'm implementing a new machine learning algorithm in Java that extracts a prototype datastructure from a set of structured datasets (tree-structure). As im developing a generic library for that purpose, i kept my design independent from concrete data-representations like XML. My problem now is that I need a way to define a data model, which is basically a ruleset describing valid trees, against which a set of trees is being matched. I thought of using BNF or a similar dialect. Basically I need a way to iterate through the space of all valid TreeNodes defined by the ModelTree (Like a search through the search space for algorithms like A*) so that i can compare my set of concrete trees with the model. I know that I'll have to deal with infinite spaces there but first things first. I know, it's rather tricky (and my sentences are pretty bumpy) but I would appreciate any clues. Thanks in advance, Stefan

    Read the article

  • How to correctly formalize the command line usage of GNU/Linux commands?

    - by Francesco Turco
    I'd like to write down a BNF-like formal grammar for describing the command line usage of some GNU/Linux tools. For example I can describe the usage of the cat command as: (cat-command) : 'cat' (arguments-list) (arguments-list) : (argument) (arguments-list) : (arguments-list) (argument) (argument) : (file) The problem is I can't write down a precise grammar for some commands such as md5sum. My first attempt at that would be the following: (md5sum-command) : 'md5sum' (arguments-list) (arguments-list) : (argument) (arguments-list) : (arguments-list) (argument) (argument) : (file) (argument) : '--check' But as you can see this grammar allows you to specify the --check argument as many times as you wish, which is incorrect as you should use it at most one time. How can I fix that? Also, what kind of formal grammars I should study for better treating this kind of problems? 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

  • Is there a standard lexer/parser tool for Python?

    - by Salim Fadhley
    A volunteer job requires us to convert a large number of LaTeX documents into ePub format. It's a series of open-source fiction book which has so far only been produced only on paper via a print on demand service. We'd like to be able to offer the book to users of book-reader devices (such as Kindle) which require the ePub format for best results. Fortunately, ePub is a very simple format, however there's no trivial way for LaTeX to produce the XHTML outut required. We experimented with alternative LaTeX compilers (e.g. plastex) but in the end we figured that it would probably be a lot easier to simply write our own compiler which understands a tiny subset of the LaTeX language and compiles directly to XHTML / ePub. Previously I used a tool on Windows called GOLD. This allowed me to go directly from BNF grammars to a stub parser. It also alllowed me to implement the parser in any language I liked. (I'd choose Python). This product has to work on Linux, so I'm wondering if there's an equivalent toolchain that works as well under Ubutnu / Eclipse / Python. The idea is that we will take the grammar of TeX and just implement a teeny subset of that, but we do not want to spend a huge amount of time worrying about grammar and parsing. A parser generator would obviously save us a great deal of time. Sal UPDATE 1: Bonus marks for a solution with excellent documentation or tutorials.

    Read the article

  • String Manipulation in C

    - by baris_a
    Hi guys, I am helping my nephew for his C lab homework, it is a string manipulation assignment and applying Wang's algorithm. Here is the BNF representation for the input. <sequent> ::= <lhs> # <rhs> <lhs> ::= <formulalist>| e <rhs> ::= <formulalist>| e <formulalist> ::= <formula>|<formula> , <formulalist> <formula> ::= <letter>| - <formula>| (<formula><in?xop><formula>) <in?xop> ::= & | | | > <letter> ::= A | B | ... | Z What is the best practice to handle and parse this kind of input in C? How can I parse this structure without using struct? Thanks in advance.

    Read the article

  • Where can I get material for learning EBNF?

    - by yesraaj
    Extended Backus–Naur Form: EBNF I'm very new to parsing concepts. Where can I get sufficiently easy to read and follow material for writing a grammar for the boost::spirit library, which uses a grammar similar to EBNF? Currently I am looking into EBNF from Wikipedia.

    Read the article

  • What quality, parser-generator options exist for ruby?

    - by cartoonfox
    What open source (preferably gem-based) parser-generator options do I have in Ruby? I've used (flex&bison)|(lex&yacc) from C in the past, and I'm comfortable with BNF-style specifications. I've heard of treetop, but it looks a bit alien and verbose compared to yacc... Purpose: I want to convert my text markup language to a BNF and generate the parsing code. I think it's a better strategy than my first-order solution: http://github.com/dafydd/semantictext/blob/master/lib/semantictext/rich_text_parser.rb

    Read the article

  • What grammar based parser-generator tools exist for ruby?

    - by cartoonfox
    What open source (preferably gem-based) parser-generator options do I have in Ruby? I've used (flex&bison)|(lex&yacc) from C in the past, and I'm comfortable with BNF-style specifications. I've heard of treetop, but it looks a bit alien and verbose compared to yacc... Purpose: I want to convert my text markup language to a BNF and generate the parsing code. I think it's a better strategy than my first-order solution: http://github.com/dafydd/semantictext/blob/master/lib/semantictext/rich_text_parser.rb

    Read the article

  • How to diagram custom programming languages, non textual?

    - by Adam
    I've used and created domain-specific languages before, plenty of times (e.g. using yacc/lex). Normally we'd start with grammar written in BNF, and a bunch of keywords. This is easy to do, easy to share. Recently, I've started working with diagrammatic programming languages - closest parallel is circuit-diagrams in electronics, where it's very difficult to express ideas in text, but very easy to express them in wiring-diagrams. This is a new and novel problem for me: how to efficiently express these mini-languages, and share concepts in them with colleagues? (i.e. how to whiteboard-program within them. Actual programming is easy - you have physical components to hand) Are there tools for this? Or good/best practices (e.g. equivalent of "always use BNF as starting point for your new DSL, and use tools like yacc to generate the parser, compiler, etc"). My googlefu is proving weak - all I get is false positives for wiring diagrams, and UML editors (since these are custom languages, UML doesn't seem to help)

    Read the article

  • Dijkstra’s algorithm and functions

    - by baris_a
    Hi guys, the question is: suppose I have an input function like sin(2-cos(3*A/B)^2.5)+0.756*(C*D+3-B) specified with a BNF, I will parse input using recursive descent algorithm, and then how can I use or change Dijkstra’s algorithm to handle this given function? After parsing this input function, I need to execute it with variable inputs, where Dijkstra’s algorithm should do the work. Thanks in advance. EDIT: May be I should ask also: What is the best practice or data structure to represent given function?

    Read the article

  • Design a mini script language

    - by radi
    hi , my project this year is to develop a text mining tool (with new features) so we need a mini script language in this tool to add annotation to texts this language should be simple and like lisp grammars (left and right side) . what i need is how to design this language ,i know how to constract the compiler , but how to write language grammars ? , and i want to use some mini open source language or any language bnf please advice me and if there is a language i can use and customize to meet my needs ? thanks

    Read the article

  • Why is CS never a topic of conversation of the layman? [closed]

    - by hydroparadise
    Granted, every profession has it's technicalities. If you are an MD, you better know the anatomy of the human body, and if you are astronomer, you better know your calculus. Yet, you don't have to know these more advance topics to know that smoking might give you lung cancer because of carcinogens or the moon revolves around the earth because of gravity (thank you Discovery Channel). There's sort of a common knowledge (at least in more developed countries) of these more advanced topics. With that said, why are things like recursive descent parsing, BNF, or Turing machines hardly ever mentioned outsided 3000 or 4000 level classes in a university setting or between colleagues? Even back in my days before college in my pursuit of knowledge on how computers work, these very important topics (IMHO) never seem to get the light of day. Many different sources and sites go into "What is a processor?" or "What is RAM?", or "What is an OS?". You might get lucky and discover something about programming languages and how they play a role in how applications are created, but nothing about the tools for creating the language itself. To extend this idea, Dennis Ritchie died shortly after Steve Jobs, yet Dennis Ritchie got very little press compared to Steve Jobs. So, the heart of my question: Does the public in general not care to hear about computer science topics that make the technology in their lives work, or does the computer science community not lend itself to the general public to close the knowledge gap? Am I wrong to think the general public has the same thirst for knowledge on how things work as I do? Please consider the question carefully before answering or vote closing please.

    Read the article

  • What's the best way to explain parsing to a new programmer?

    - by Daisetsu
    I am a college student getting my Computer Science degree. A lot of my fellow students really haven't done a lot of programming. They've done their class assignments, but let's be honest here those questions don't really teach you how to program. I have had several other students ask me questions about how to parse things, and I'm never quite sure how to explain it to them. Is it best to start just going line by line looking for substrings, or just give them the more complicated lecture about using proper lexical analysis, etc. to create tokens, use BNF, and all of that other stuff? They never quite understand it when I try to explain it. What's the best approach to explain this without confusing them or discouraging them from actually trying.

    Read the article

  • Patterns to implement this grammar into C# code

    - by MexicanHacker
    Hey guys, I'm creating this little BNF grammar and I wanted to <template>::= <types><editors> <types>::= <type>+ <type>::= <property>+ <property>::= <name><type> <editors>::= <editor>+ <editor>::= <name><type>(<textfield>|<form>|<list>|<pulldown>)+ <textfield>::= <label><property>[<editable>] <form>::= <label><property><editor> <list>::= <label><property><item-editor> <pulldown>::= <label><property><option>+ <option>::= <value> One possible solution we have in mind is to create POCO's that have annotations of the XMLSerialization namespace, like this, for example: [XMLRoot("template")] public class Template{ [XMLElement("types")] public Types types{ } } However I want to explore more solutions, what do you guys think?

    Read the article

  • shift reduce&& reduce reduce errors in build parser for python garmmer

    - by user366580
    i wanna build buttom up parser by java cup i write code in java cup , it is for python language so i used grammer was written in this site : but not all grammer , i choice partial set ,just while , identifer also i smiplified them when i did compile for the java cup that i write by write this command in command prompt window : java java_cup.Main -parser CalcParser -symbols CalcSymbol < javacupfile.cup i get conflict errors ,they are of type reduce-shift conflict and reduce-reduce conflict you can see to print screen of the errors in these links image 1 click here to see imge1 the grammer was in EBNF form in as refernce site and i convert it to BNF form maybe i make mistake in converting so i get such errors the origanl grammmer was // grammer in EBNF form identifier ::= (letter|"_") (letter | digit | "_")* letter ::= lowercase | uppercase lowercase ::= "a"..."z" uppercase ::= "A"..."Z" digit ::= "0"..."9 compound_stmt ::= if_stmt | while_stmt for_stmt ::= "for" target_list "in" expression_list ":" suite ["else" ":" suite] while_stmt ::= "while" expression ":" suite ["else" ":" suite] suite ::= stmt_list NEWLINE stmt_list ::= simple_stmt (";" simple_stmt)* [";"] simple_stmt ::= expression_stmt expression_stmt ::= expression_list expression_list ::= expression ( "," expression )* [","] expression ::= conditional_expression conditional_expression ::= or_test ["if" or_test "else" expression] or_test ::= and_test | or_test "or" and_test and_test ::= not_test | and_test "and" not_test not_test ::= comparison | "not" not_test comparison ::= or_expr ( comp_operator or_expr )* comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "<>" | "!=" | "is" ["not"] | ["not"] "in" or_expr ::= xor_expr | or_expr "|" xor_expr xor_expr ::= and_expr | xor_expr "^" and_expr and_expr ::= "&" | and_expr the grammer after converting to BNF form identifier ::=letterletter| letterdigit| letter"_"| "_"letter | "_"digit | "_""_" letter ::= lowercase | uppercase lowercase ::= "a"..."z" uppercase ::= "A"..."Z" digit ::= "0"..."9 while_stmt ::= "while" expression ":" suite "else" ":" suite |"while" expression ":" suite suite ::= stmt_list NEWLINE stmt_list ::= simple_stmt ";" simple_stmt stmt_list|";" simple_stmt ::= expression_stmt expression_stmt ::= expression_list expression_list ::= expression "," expression expression_list| "," expression ::= conditional_expression conditional_expression ::= or_test "if" or_test "else" expression |or_test or_test ::= and_test | or_test "or" and_test and_test ::= not_test | and_test "and" not_test not_test ::= comparison | "not" not_test comparison ::= or_expr comp_operator or_expr comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "<>" | "!=" | "is" ["not"] | ["not"] "in" or_expr ::= xor_expr | or_expr "|" xor_expr xor_expr ::= and_expr | xor_expr "^" and_expr and_expr ::= "&" | and_expr and the java cup file that i compile and get those errors is import java.io.*; terminal COMA; terminal ELSE; terminal WHILE; terminal NEWLINE; terminal SEMCOLON; terminal CAMMA; terminal IF; terminal OR; terminal AND; terminal NOT; terminal LESS; terminal GREATER; terminal EQUAL; terminal GREATERorE; terminal LESSorE; terminal NEQUAL; terminal OROP; terminal XOROP; terminal ANDOP; terminal Integer DIGIT; terminal java.lang.String LOWERCASE; terminal java.lang.String UPPERCASE; non terminal java.lang.String IDENTIFIER; non terminal java.lang.String LETTER; non terminal COMPOUND_STMT; non terminal WHILE_STMT; non terminal EXPRESSION; non terminal SUITE ; non terminal STMT_LIST; non terminal SIMPLE_STMT; non terminal EXPRESSION_STMT; non terminal EXPRESSION_LIST; non terminal CONDITITONAL_EXPRESSION; non terminal OR_TEST; non terminal AND_TEST; non terminal NOT_TEST; non terminal COMPARISON; non terminal COMP_OPERATOR; non terminal OR_EXPR; non terminal XOR_EXPR; non terminal AND_EXPR; IDENTIFIER ::=LETTER{: System.out.printf("lowercase"); :}| {: System.out.printf("uppercase"); :} LETTER{: System.out.printf("lowercase"); :}| {: System.out.printf("uppercase"); :}| LETTER{: System.out.printf("lowercase"); :}| {: System.out.printf("uppercase"); :} DIGIT; LETTER ::= LOWERCASE | UPPERCASE; COMPOUND_STMT ::=WHILE_STMT; WHILE_STMT ::= WHILE{: System.out.printf( "while"); :} EXPRESSION COMA {: System.out.printf(":"); :} SUITE ELSE {: System.out.printf("else" ); :} COMA{: System.out.printf( ":" ); :} SUITE |WHILE{: System.out.printf( "while" ); :} EXPRESSION COMA{: System.out.printf( ":" ); :} SUITE; SUITE ::= STMT_LIST NEWLINE{: System.out.printf( "newline" ); :}; STMT_LIST ::= SIMPLE_STMT SEMCOLON{: System.out.printf( ";" ); :} SIMPLE_STMT STMT_LIST|SEMCOLON{: System.out.printf( ";" ); :}; SIMPLE_STMT ::=EXPRESSION_STMT; EXPRESSION_STMT ::=EXPRESSION_LIST; EXPRESSION_LIST ::= EXPRESSION CAMMA{: System.out.printf( "," ); :} EXPRESSION EXPRESSION_LIST| CAMMA{: System.out.printf( "," ); :}; EXPRESSION ::= CONDITITONAL_EXPRESSION; CONDITITONAL_EXPRESSION ::= OR_TEST IF{: System.out.printf( "if"); :} OR_TEST ELSE{: System.out.printf("else"); :} EXPRESSION |OR_TEST; OR_TEST ::= AND_TEST | OR_TEST OR{: System.out.printf( "or"); :} AND_TEST; AND_TEST ::= NOT_TEST | AND_TEST AND{: System.out.printf( "and"); :} NOT_TEST; NOT_TEST ::= COMPARISON | NOT{: System.out.printf("not"); :} NOT_TEST; COMPARISON ::= OR_EXPR COMP_OPERATOR OR_EXPR ; COMP_OPERATOR ::= LESS{: System.out.printf( "<"); :} | GREATER{: System.out.printf(">"); :} | EQUAL{: System.out.printf("=="); :} | GREATERorE{: System.out.printf(">="); :} | LESSorE{: System.out.printf("<="); :} | NEQUAL{: System.out.printf("!="); :}; OR_EXPR ::= XOR_EXPR | OR_EXPR OROP{: System.out.printf("|"); :} XOR_EXPR; XOR_EXPR ::= AND_EXPR | XOR_EXPR XOROP {: System.out.printf("^"); :}XOR_EXPR; AND_EXPR ::= ANDOP{: System.out.printf("&"); :} | AND_EXPR; can any one told me how can solve this errors to build parser correcrtly??

    Read the article

1 2  | Next Page >