comp.lang.ada
 help / color / mirror / Atom feed
* Free Ada parser
@ 2003-12-09 18:10 J Quirce
  2003-12-09 19:27 ` David C. Hoos
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: J Quirce @ 2003-12-09 18:10 UTC (permalink / raw)


Hi, 

I am just joining the group after a quite long and discusting weg
search of any kind of "executable ada grammar". I mean, an Ada 95 one
ready for processing by Yacc, Bison or any other more or less
reasonable compiler compiler.

Do you have any idea on where can I get it?

Thanks, 

J. Quirce



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Free Ada parser
  2003-12-09 18:10 Free Ada parser J Quirce
@ 2003-12-09 19:27 ` David C. Hoos
  2003-12-10 13:10   ` Oliver Kellogg
  2003-12-10  8:11 ` Ole-Hjalmar Kristensen
  2003-12-13 22:57 ` Craig Carey
  2 siblings, 1 reply; 12+ messages in thread
From: David C. Hoos @ 2003-12-09 19:27 UTC (permalink / raw)
  To: J Quirce, comp.lang.ada@ada.eu.org

[-- Attachment #1: Type: text/plain, Size: 906 bytes --]

The attached file is approaching ten years old, but is the latest one of
which I know.

The e-mail address of the author has changed in the meantime.

He can be reached at Tucker Taft <stt@sofcheck.com>

----- Original Message ----- 
From: "J Quirce" <jesus.quirce.garcia@esa.int>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada-france.org>
Sent: Tuesday, December 09, 2003 12:10 PM
Subject: Free Ada parser


> Hi, 
> 
> I am just joining the group after a quite long and discusting weg
> search of any kind of "executable ada grammar". I mean, an Ada 95 one
> ready for processing by Yacc, Bison or any other more or less
> reasonable compiler compiler.
> 
> Do you have any idea on where can I get it?
> 
> Thanks, 
> 
> J. Quirce
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada-france.org
> http://www.ada-france.org/mailman/listinfo/comp.lang.ada
> 

[-- Attachment #2: grammar9x.y.txt --]
[-- Type: text/plain, Size: 18720 bytes --]

/******* A YACC grammar for Ada 9X *********************************/
/* Copyright (C) Intermetrics, Inc. 1994 Cambridge, MA  USA        */
/* Copying permitted if accompanied by this statement.             */
/* Derivative works are permitted if accompanied by this statement.*/
/* This grammar is thought to be correct as of May 1, 1994         */
/* but as usual there is *no warranty* to that effect.             */
/*******************************************************************/

%token TIC
%token DOT_DOT
%token LT_LT
%token BOX
%token LT_EQ
%token EXPON
%token NE
%token GT_GT
%token GE
%token IS_ASSIGNED
%token RIGHT_SHAFT
%token ABORT
%token ABS
%token ABSTRACT
%token ACCEPT
%token ACCESS
%token ALIASED
%token ALL
%token AND
%token ARRAY
%token AT
%token BEGiN
%token BODY
%token CASE
%token CONSTANT
%token DECLARE
%token DELAY
%token DELTA
%token DIGITS
%token DO
%token ELSE
%token ELSIF
%token END
%token ENTRY
%token EXCEPTION
%token EXIT
%token FOR
%token FUNCTION
%token GENERIC
%token GOTO
%token IF
%token IN
%token IS
%token LIMITED
%token LOOP
%token MOD
%token NEW
%token NOT
%token NuLL
%token OF
%token OR
%token OTHERS
%token OUT
%token PACKAGE
%token PRAGMA
%token PRIVATE
%token PROCEDURE
%token PROTECTED
%token RAISE
%token RANGE
%token RECORD
%token REM
%token RENAMES
%token REQUEUE
%token RETURN
%token REVERSE
%token SELECT
%token SEPARATE
%token SUBTYPE
%token TAGGED
%token TASK
%token TERMINATE
%token THEN
%token TYPE
%token UNTIL
%token USE
%token WHEN
%token WHILE
%token WITH
%token XOR
%token char_lit
%token identifier
%token char_string
%token numeric_lit

%{
%}

%%

goal_symbol : compilation
	;

pragma  : PRAGMA identifier ';'
	| PRAGMA simple_name '(' pragma_arg_s ')' ';'
	;

pragma_arg_s : pragma_arg
	| pragma_arg_s ',' pragma_arg
	;

pragma_arg : expression
	| simple_name RIGHT_SHAFT expression
	;

pragma_s :
	| pragma_s pragma
	;

decl    : object_decl
	| number_decl
	| type_decl
	| subtype_decl
	| subprog_decl
	| pkg_decl
	| task_decl
	| prot_decl
	| exception_decl
	| rename_decl
	| generic_decl
	| body_stub
	| error ';'
	;

object_decl : def_id_s ':' object_qualifier_opt object_subtype_def init_opt ';'
	;

def_id_s : def_id
	| def_id_s ',' def_id
	;

def_id  : identifier
	;

object_qualifier_opt :
	| ALIASED
	| CONSTANT
	| ALIASED CONSTANT
	;

object_subtype_def : subtype_ind
	| array_type
	;

init_opt :
	| IS_ASSIGNED expression
	;

number_decl : def_id_s ':' CONSTANT IS_ASSIGNED expression ';'
	;

type_decl : TYPE identifier discrim_part_opt type_completion ';'
	;

discrim_part_opt :
	| discrim_part
	| '(' BOX ')'
	;

type_completion :
	| IS type_def
	;

type_def : enumeration_type 
	| integer_type
	| real_type
	| array_type
	| record_type
	| access_type
	| derived_type
	| private_type
	;

subtype_decl : SUBTYPE identifier IS subtype_ind ';'
	;

subtype_ind : name constraint
	| name
	;

constraint : range_constraint
	| decimal_digits_constraint
	;

decimal_digits_constraint : DIGITS expression range_constr_opt
	;

derived_type : NEW subtype_ind
	| NEW subtype_ind WITH PRIVATE
	| NEW subtype_ind WITH record_def
	| ABSTRACT NEW subtype_ind WITH PRIVATE
	| ABSTRACT NEW subtype_ind WITH record_def
	;

range_constraint : RANGE range
	;

range : simple_expression DOT_DOT simple_expression
	| name TIC RANGE
	| name TIC RANGE '(' expression ')'
	;

enumeration_type : '(' enum_id_s ')'

enum_id_s : enum_id
	| enum_id_s ',' enum_id
	;

enum_id : identifier
	| char_lit
	;

integer_type : range_spec
	| MOD expression
	;
	

range_spec : range_constraint
	;

range_spec_opt :
	| range_spec
	;

real_type : float_type
	| fixed_type
	;

float_type : DIGITS expression range_spec_opt
	;

fixed_type : DELTA expression range_spec
	| DELTA expression DIGITS expression range_spec_opt
	;

array_type : unconstr_array_type
	| constr_array_type
	;

unconstr_array_type : ARRAY '(' index_s ')' OF component_subtype_def
	;

constr_array_type : ARRAY iter_index_constraint OF component_subtype_def
	;

component_subtype_def : aliased_opt subtype_ind
	;

aliased_opt : 
	| ALIASED
	;

index_s : index
	| index_s ',' index
	;

index : name RANGE BOX
	;

iter_index_constraint : '(' iter_discrete_range_s ')'
	;

iter_discrete_range_s : discrete_range
	| iter_discrete_range_s ',' discrete_range
	;

discrete_range : name range_constr_opt
	| range
	;

range_constr_opt :
	| range_constraint
	;

record_type : tagged_opt limited_opt record_def
	;

record_def : RECORD pragma_s comp_list END RECORD
	| NuLL RECORD
	;

tagged_opt :
	| TAGGED
	| ABSTRACT TAGGED
	;

comp_list : comp_decl_s variant_part_opt
	| variant_part pragma_s
	| NuLL ';' pragma_s
	;

comp_decl_s : comp_decl
	| comp_decl_s pragma_s comp_decl
	;

variant_part_opt : pragma_s
	| pragma_s variant_part pragma_s
	;

comp_decl : def_id_s ':' component_subtype_def init_opt ';'
	| error ';'
	;

discrim_part : '(' discrim_spec_s ')'
	;

discrim_spec_s : discrim_spec
	| discrim_spec_s ';' discrim_spec
	;

discrim_spec : def_id_s ':' access_opt mark init_opt
	| error
	;

access_opt :
	| ACCESS
	;

variant_part : CASE simple_name IS pragma_s variant_s END CASE ';'
	;

variant_s : variant
	| variant_s variant
	;

variant : WHEN choice_s RIGHT_SHAFT pragma_s comp_list
	;

choice_s : choice
	| choice_s '|' choice
	;

choice : expression
	| discrete_with_range
	| OTHERS
	;

discrete_with_range : name range_constraint
	| range
	;

access_type : ACCESS subtype_ind
	| ACCESS CONSTANT subtype_ind
	| ACCESS ALL subtype_ind
	| ACCESS prot_opt PROCEDURE formal_part_opt
	| ACCESS prot_opt FUNCTION formal_part_opt RETURN mark
	;

prot_opt :
	| PROTECTED
	;

decl_part :
	| decl_item_or_body_s1
	;

decl_item_s : 
	| decl_item_s1
	;

decl_item_s1 : decl_item
	| decl_item_s1 decl_item
	;

decl_item : decl
	| use_clause
	| rep_spec
	| pragma
	;

decl_item_or_body_s1 : decl_item_or_body
	| decl_item_or_body_s1 decl_item_or_body
	;

decl_item_or_body : body
	| decl_item
	;

body : subprog_body
	| pkg_body
	| task_body
	| prot_body
	;

name : simple_name
	| indexed_comp
	| selected_comp
	| attribute
	| operator_symbol
	;

mark : simple_name
	| mark TIC attribute_id
	| mark '.' simple_name
	;

simple_name : identifier
	;

compound_name : simple_name
	| compound_name '.' simple_name
	;

c_name_list : compound_name
	 | c_name_list ',' compound_name
	;

used_char : char_lit
	;

operator_symbol : char_string
	;

indexed_comp : name '(' value_s ')'
	;

value_s : value
	| value_s ',' value
	;

value : expression
	| comp_assoc
	| discrete_with_range
	| error
	;

selected_comp : name '.' simple_name
	| name '.' used_char
	| name '.' operator_symbol
	| name '.' ALL
	;

attribute : name TIC attribute_id
	;

attribute_id : identifier
	| DIGITS
	| DELTA
	| ACCESS
	;

literal : numeric_lit
	| used_char
	| NuLL
	;

aggregate : '(' comp_assoc ')'
	| '(' value_s_2 ')'
	| '(' expression WITH value_s ')'
	| '(' expression WITH NuLL RECORD ')'
	| '(' NuLL RECORD ')'
	;

value_s_2 : value ',' value
	| value_s_2 ',' value
	;

comp_assoc : choice_s RIGHT_SHAFT expression
	;

expression : relation
	| expression logical relation
	| expression short_circuit relation
	;

logical : AND
	| OR
	| XOR
	;

short_circuit : AND THEN
	| OR ELSE
	;

relation : simple_expression
	| simple_expression relational simple_expression
	| simple_expression membership range
	| simple_expression membership name
	;

relational : '='
	| NE
	| '<'
	| LT_EQ
	| '>'
	| GE
	;

membership : IN
	| NOT IN
	;

simple_expression : unary term
	| term
	| simple_expression adding term
	;

unary   : '+'
	| '-'
	;

adding  : '+'
	| '-'
	| '&'
	;

term    : factor
	| term multiplying factor
	;

multiplying : '*'
	| '/'
	| MOD
	| REM
	;

factor : primary
	| NOT primary
	| ABS primary
	| primary EXPON primary
	;

primary : literal
	| name
	| allocator
	| qualified
	| parenthesized_primary
	;

parenthesized_primary : aggregate
	| '(' expression ')'
	;

qualified : name TIC parenthesized_primary
	;

allocator : NEW name
	| NEW qualified
	;

statement_s : statement
	| statement_s statement
	;

statement : unlabeled
	| label statement
	;

unlabeled : simple_stmt
	| compound_stmt
	| pragma
	;

simple_stmt : null_stmt
	| assign_stmt
	| exit_stmt
	| return_stmt
	| goto_stmt
	| procedure_call
	| delay_stmt
	| abort_stmt
	| raise_stmt
	| code_stmt
	| requeue_stmt
	| error ';'
	;

compound_stmt : if_stmt
	| case_stmt
	| loop_stmt
	| block
	| accept_stmt
	| select_stmt
	;

label : LT_LT identifier GT_GT
	;

null_stmt : NuLL ';'
	;

assign_stmt : name IS_ASSIGNED expression ';'
	;

if_stmt : IF cond_clause_s else_opt END IF ';'
	;

cond_clause_s : cond_clause
	| cond_clause_s ELSIF cond_clause
	;

cond_clause : cond_part statement_s
	;

cond_part : condition THEN
	;

condition : expression
	;

else_opt :
	| ELSE statement_s
	;

case_stmt : case_hdr pragma_s alternative_s END CASE ';'
	;

case_hdr : CASE expression IS
	;

alternative_s :
	| alternative_s alternative
	;

alternative : WHEN choice_s RIGHT_SHAFT statement_s
	;

loop_stmt : label_opt iteration basic_loop id_opt ';'
	;

label_opt :
	| identifier ':'
	;

iteration :
	| WHILE condition
	| iter_part reverse_opt discrete_range
	;

iter_part : FOR identifier IN
	;

reverse_opt :
	| REVERSE
	;

basic_loop : LOOP statement_s END LOOP
	;

id_opt :
	| designator
	;

block : label_opt block_decl block_body END id_opt ';'
	;

block_decl :
	| DECLARE decl_part
	;

block_body : BEGiN handled_stmt_s
	;

handled_stmt_s : statement_s except_handler_part_opt 
	; 

except_handler_part_opt :
	| except_handler_part
	;

exit_stmt : EXIT name_opt when_opt ';'
	;

name_opt :
	| name
	;

when_opt :
	| WHEN condition
	;

return_stmt : RETURN ';'
	| RETURN expression ';'
	;

goto_stmt : GOTO name ';'
	;

subprog_decl : subprog_spec ';'
	| generic_subp_inst ';'
	| subprog_spec_is_push ABSTRACT ';'
	;

subprog_spec : PROCEDURE compound_name formal_part_opt
	| FUNCTION designator formal_part_opt RETURN name
	| FUNCTION designator  /* for generic inst and generic rename */
	;

designator : compound_name
	| char_string
	;

formal_part_opt : 
	| formal_part
	;

formal_part : '(' param_s ')'
	;

param_s : param
	| param_s ';' param
	;

param : def_id_s ':' mode mark init_opt
	| error
	;

mode :
	| IN
	| OUT
	| IN OUT
	| ACCESS
	;

subprog_spec_is_push : subprog_spec IS
	;

subprog_body : subprog_spec_is_push
	       decl_part block_body END id_opt ';'
	;

procedure_call : name ';'
	;

pkg_decl : pkg_spec ';'
	| generic_pkg_inst ';'
	;

pkg_spec : PACKAGE compound_name IS 
	     decl_item_s private_part END c_id_opt
	;

private_part :
	| PRIVATE decl_item_s
	;

c_id_opt : 
	| compound_name
	;

pkg_body : PACKAGE BODY compound_name IS
	       decl_part body_opt END c_id_opt ';'
	;

body_opt :
	| block_body
	;

private_type : tagged_opt limited_opt PRIVATE
	;

limited_opt :
	| LIMITED
	;

use_clause : USE name_s ';'
	| USE TYPE name_s ';'
	;

name_s : name
	| name_s ',' name
	;

rename_decl : def_id_s ':' object_qualifier_opt subtype_ind renames ';'
	| def_id_s ':' EXCEPTION renames ';'
	| rename_unit
	;

rename_unit : PACKAGE compound_name renames ';'
	| subprog_spec renames ';'
	| generic_formal_part PACKAGE compound_name renames ';'
	| generic_formal_part subprog_spec renames ';'
	;

renames : RENAMES name
	;

task_decl : task_spec ';'
	;

task_spec : TASK simple_name task_def
	| TASK TYPE simple_name discrim_part_opt task_def
	;

task_def :
	| IS entry_decl_s rep_spec_s task_private_opt END id_opt
	;

task_private_opt :
	| PRIVATE entry_decl_s rep_spec_s
	;

task_body : TASK BODY simple_name IS
	       decl_part block_body END id_opt ';'
	;

prot_decl : prot_spec ';'
	;

prot_spec : PROTECTED identifier prot_def
	| PROTECTED TYPE simple_name discrim_part_opt prot_def
	;

prot_def : IS prot_op_decl_s prot_private_opt END id_opt
	;

prot_private_opt :
	| PRIVATE prot_elem_decl_s 


prot_op_decl_s : 
	| prot_op_decl_s prot_op_decl
	;

prot_op_decl : entry_decl
	| subprog_spec ';'
	| rep_spec
	| pragma
	;

prot_elem_decl_s : 
	| prot_elem_decl_s prot_elem_decl
	;

prot_elem_decl : prot_op_decl | comp_decl ;

prot_body : PROTECTED BODY simple_name IS
	       prot_op_body_s END id_opt ';'
	;

prot_op_body_s : pragma_s
	| prot_op_body_s prot_op_body pragma_s
	;

prot_op_body : entry_body
	| subprog_body
	| subprog_spec ';'
	;

entry_decl_s : pragma_s
	| entry_decl_s entry_decl pragma_s
	;

entry_decl : ENTRY identifier formal_part_opt ';'
	| ENTRY identifier '(' discrete_range ')' formal_part_opt ';'
	;

entry_body : ENTRY identifier formal_part_opt WHEN condition entry_body_part
	| ENTRY identifier '(' iter_part discrete_range ')' 
		formal_part_opt WHEN condition entry_body_part
	;

entry_body_part : ';'
	| IS decl_part block_body END id_opt ';'
	;

rep_spec_s :
	| rep_spec_s rep_spec pragma_s
	;

entry_call : procedure_call
	;

accept_stmt : accept_hdr ';'
	| accept_hdr DO handled_stmt_s END id_opt ';'
	;

accept_hdr : ACCEPT entry_name formal_part_opt
	;

entry_name : simple_name
	| entry_name '(' expression ')'
	;

delay_stmt : DELAY expression ';'
	| DELAY UNTIL expression ';'
	;

select_stmt : select_wait
	| async_select
	| timed_entry_call
	| cond_entry_call
	;

select_wait : SELECT guarded_select_alt or_select else_opt
	      END SELECT ';'
	;

guarded_select_alt : select_alt
	| WHEN condition RIGHT_SHAFT select_alt
	;

or_select :
	| or_select OR guarded_select_alt
	;

select_alt : accept_stmt stmts_opt
	| delay_stmt stmts_opt
	| TERMINATE ';'
	;

delay_or_entry_alt : delay_stmt stmts_opt
	| entry_call stmts_opt

async_select : SELECT delay_or_entry_alt
	       THEN ABORT statement_s
	       END SELECT ';'
	;

timed_entry_call : SELECT entry_call stmts_opt 
		   OR delay_stmt stmts_opt
	           END SELECT ';'
	;

cond_entry_call : SELECT entry_call stmts_opt 
		  ELSE statement_s
	          END SELECT ';'
	;

stmts_opt :
	| statement_s
	;

abort_stmt : ABORT name_s ';'
	;

compilation :
	| compilation comp_unit
	| pragma pragma_s
	;

comp_unit : context_spec private_opt unit pragma_s
	| private_opt unit pragma_s
	;

private_opt :
	| PRIVATE
	;

context_spec : with_clause use_clause_opt
	| context_spec with_clause use_clause_opt
	| context_spec pragma
	;

with_clause : WITH c_name_list ';'
	;

use_clause_opt :
	| use_clause_opt use_clause
	;

unit : pkg_decl
	| pkg_body
	| subprog_decl
	| subprog_body
	| subunit
	| generic_decl
	| rename_unit
	;

subunit : SEPARATE '(' compound_name ')'
	      subunit_body
	;

subunit_body : subprog_body
	| pkg_body
	| task_body
	| prot_body
	;

body_stub : TASK BODY simple_name IS SEPARATE ';'
	| PACKAGE BODY compound_name IS SEPARATE ';'
	| subprog_spec IS SEPARATE ';'
	| PROTECTED BODY simple_name IS SEPARATE ';'
	;

exception_decl : def_id_s ':' EXCEPTION ';'
	;

except_handler_part : EXCEPTION exception_handler
	| except_handler_part exception_handler
	;

exception_handler : WHEN except_choice_s RIGHT_SHAFT statement_s
	| WHEN identifier ':' except_choice_s RIGHT_SHAFT statement_s
	;

except_choice_s : except_choice
	| except_choice_s '|' except_choice
	;

except_choice : name
	| OTHERS
	;

raise_stmt : RAISE name_opt ';'
	;

requeue_stmt : REQUEUE name ';'
	| REQUEUE name WITH ABORT ';'
	;

generic_decl : generic_formal_part subprog_spec ';'
	| generic_formal_part pkg_spec ';'
	;
generic_formal_part : GENERIC
	| generic_formal_part generic_formal
	;

generic_formal : param ';'
	| TYPE simple_name generic_discrim_part_opt IS generic_type_def ';'
	| WITH PROCEDURE simple_name 
	    formal_part_opt subp_default ';'
	| WITH FUNCTION designator 
	    formal_part_opt RETURN name subp_default ';'
	| WITH PACKAGE simple_name IS NEW name '(' BOX ')' ';'
	| WITH PACKAGE simple_name IS NEW name ';'
	| use_clause
	;

generic_discrim_part_opt :
	| discrim_part
	| '(' BOX ')'
	;

subp_default :
	| IS name
	| IS BOX
	;

generic_type_def : '(' BOX ')'
	| RANGE BOX
	| MOD BOX
	| DELTA BOX
	| DELTA BOX DIGITS BOX
	| DIGITS BOX
	| array_type
	| access_type
	| private_type
	| generic_derived_type
	;

generic_derived_type : NEW subtype_ind
	| NEW subtype_ind WITH PRIVATE
	| ABSTRACT NEW subtype_ind WITH PRIVATE
	;

generic_subp_inst : subprog_spec IS generic_inst
	;

generic_pkg_inst : PACKAGE compound_name IS generic_inst
	;

generic_inst : NEW name
	;

rep_spec : attrib_def
	| record_type_spec
	| address_spec
	;

attrib_def : FOR mark USE expression ';'
	;

record_type_spec : FOR mark USE RECORD align_opt comp_loc_s END RECORD ';'
	;

align_opt :
	| AT MOD expression ';'
	;

comp_loc_s :
	| comp_loc_s mark AT expression RANGE range ';'
	;

address_spec : FOR mark USE AT expression ';'
	;

code_stmt : qualified ';'
	;

%%


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Free Ada parser
  2003-12-09 18:10 Free Ada parser J Quirce
  2003-12-09 19:27 ` David C. Hoos
@ 2003-12-10  8:11 ` Ole-Hjalmar Kristensen
  2003-12-13 22:57 ` Craig Carey
  2 siblings, 0 replies; 12+ messages in thread
From: Ole-Hjalmar Kristensen @ 2003-12-10  8:11 UTC (permalink / raw)



http://www.antlr.org/grammar/ada

-- 
Strange attractors stole my wife



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Free Ada parser
  2003-12-09 19:27 ` David C. Hoos
@ 2003-12-10 13:10   ` Oliver Kellogg
  0 siblings, 0 replies; 12+ messages in thread
From: Oliver Kellogg @ 2003-12-10 13:10 UTC (permalink / raw)


The ANTLR grammar for Ada at

	http://www.antlr.org/grammar/ada

was originally based on this lex/yacc grammar, but when
looking at it you probably wouldn't know :)

--Oliver



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Free Ada parser
@ 2003-12-11 14:50 ada_wizard
  2003-12-12 21:05 ` Colin Paul Gloster
  0 siblings, 1 reply; 12+ messages in thread
From: ada_wizard @ 2003-12-11 14:50 UTC (permalink / raw)
  To: comp.lang.ada

jesus.quirce.garcia@esa.int (J Quirce) writes:

> Hi, 
> 
> I am just joining the group after a quite long and discusting weg
> search of any kind of "executable ada grammar". I mean, an Ada 95 one
> ready for processing by Yacc, Bison or any other more or less
> reasonable compiler compiler.
> 
> Do you have any idea on where can I get it?

Depending on why you want an Ada parser, there are other approaches to
consider.

The GNAT compiler, obviously, has an Ada parser. Since it is open
source, you can use it.

OpenToken
(http://www.telepath.com/~dennison/Ted/OpenToken/OpenToken.html)
provides an Ada grammar (but only at the lexical level; the parse
level for Ada is quite complex, you know :).

And then there is ASIS (available for GNAT); it lets GNAT parse (and
compile) the source code, and provides an API for you to query the
results.

So, what do you plan to do with your parser after you find it?

-- 
-- Stephe


___________________________________________________________
This mail sent using ToadMail -- Web based e-mail @ ToadNet



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Free Ada parser
  2003-12-11 14:50 ada_wizard
@ 2003-12-12 21:05 ` Colin Paul Gloster
  2003-12-13  3:02   ` Steve
  0 siblings, 1 reply; 12+ messages in thread
From: Colin Paul Gloster @ 2003-12-12 21:05 UTC (permalink / raw)


NASA veteran Stephen Leake wrote:

"jesus.quirce.garcia@esa.int (J Quirce) writes:

> Hi, 
> 
> I am just joining the group after a quite long and discusting weg
> search of any kind of "executable ada grammar". I mean, an Ada 95 one
> ready for processing by Yacc, Bison or any other more or less
> reasonable compiler compiler.
> 
> Do you have any idea on where can I get it?
  
[..]"

If Yacc-compatibility is really important, then you could try Ayacc and
Alex but I do not know whether they support Ada 95. They are on many of
the CDs posted with the journal "Ada Letters", which ESA subscribes to.

If instead a "reasonable" tool would really be top-down then you could try
the Ada 9X grammar for the Java Compiler Compiler which does not support
fixed types. The grammar is at
HTTP://WWW.Cobase.CS.UCLA.edu/pub/javacc/ada9x.jj and recent versions of
JavaCC are at HTTPS://JavaCC.dev.Java.net/



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Free Ada parser
  2003-12-12 21:05 ` Colin Paul Gloster
@ 2003-12-13  3:02   ` Steve
  2003-12-13 16:46     ` Pascal Obry
  0 siblings, 1 reply; 12+ messages in thread
From: Steve @ 2003-12-13  3:02 UTC (permalink / raw)


"Colin Paul Gloster" <Colin_Paul_Gloster@ACM.org> wrote in message
news:slrnbtkbcc.nen.Colin_Paul_Gloster@camac.dcu.ie...
[snip]
>
> If Yacc-compatibility is really important, then you could try Ayacc and
> Alex but I do not know whether they support Ada 95...

Aflex and Ayacc for GNAT may be found at:

http://www-users.cs.york.ac.uk/~bernat/resources.html

Note: I haven't used this version, but doctored up my own copy of aflex and
ayacc from a different source to work with Ada 95 several years ago and used
it then.  It worked well.

Steve
(The Duck)





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Free Ada parser
  2003-12-13  3:02   ` Steve
@ 2003-12-13 16:46     ` Pascal Obry
  0 siblings, 0 replies; 12+ messages in thread
From: Pascal Obry @ 2003-12-13 16:46 UTC (permalink / raw)



"Steve" <nospam_steved94@comcast.net> writes:

> "Colin Paul Gloster" <Colin_Paul_Gloster@ACM.org> wrote in message
> news:slrnbtkbcc.nen.Colin_Paul_Gloster@camac.dcu.ie...
> [snip]
> >
> > If Yacc-compatibility is really important, then you could try Ayacc and
> > Alex but I do not know whether they support Ada 95...
> 
> Aflex and Ayacc for GNAT may be found at:
> 
> http://www-users.cs.york.ac.uk/~bernat/resources.html

And if this version does not work you I have ported a version of aflex/ayacc
(long time ago). You can download this from my homepage.

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|         http://perso.wanadoo.fr/pascal.obry
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Free Ada parser
  2003-12-09 18:10 Free Ada parser J Quirce
  2003-12-09 19:27 ` David C. Hoos
  2003-12-10  8:11 ` Ole-Hjalmar Kristensen
@ 2003-12-13 22:57 ` Craig Carey
  2003-12-14  1:50   ` Craig Carey
  2 siblings, 1 reply; 12+ messages in thread
From: Craig Carey @ 2003-12-13 22:57 UTC (permalink / raw)




PS. Has anyone got an Ada Windows GUI program that can have embedded into
it, a user program ?. I.e. it would be like CMD.EXE, except:
 (1) it is a GUI program, and
 (2) all mouse drag selecting selects to the end of lines (and it does
     not select rectangles).
Gwindows code would be acceptable.


On 9 Dec 2003 10:10:53 -0800, ***uirce.garcia@esa.int (J Quirce) wrote:
...
>I am just joining the group after a quite long and [...]
>search of any kind of "executable ada grammar". I mean, an Ada 95 one


I uploaded a package that has merged Ada Yacc parser lines. It has a demo
program that makes of the Adagoop program. The demo program reads input
from the console and converts input to a tree and it parses it:

A new demo program showing use of Adagoop (it parses algebra expressions
read from the console (in Windows NT+)):

   http://www.ijs.co.nz/code/ada95_adagoop_parser.zip


Adagoop:   http://www.usafa.af.mil/dfcs/bios/mcc_html/ada_stuff.html

Adagoop is extensively used. 
Two other documents uses are:
  * the Ada to Lego Mindstorms programming environment,
  * the A# program that ports Ada to the Microsoft .NET Platform:

   http://www.usafa.af.mil/dfcs/adamindstorms.htm
   http://www.usafa.af.mil/dfcs/bios/mcc_html/a_sharp.html



>ready for processing by Yacc, Bison or any other more or less
>reasonable compiler compiler.
...

Would the European Space Agency be using Ada 95 for the parser?.

There is another Yacc grammar file for Ada 95, amongst the SCATC files:
   http://unicoi.kennesaw.edu/ase/support/cardcatx/scatcdsk.htm


Ada to C bindings creator: http://members.tripod.com/vagul/

I did not test and use Opentoken because of its modified GPL licence.
Since not having looked at it, I don't know how it compares with the
USAFA Adagoop software.


Craig Carey,
List of Ada 95 mailing lists: http://www.ijs.co.nz/ada_95.htm






^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Free Ada parser
  2003-12-13 22:57 ` Craig Carey
@ 2003-12-14  1:50   ` Craig Carey
  2003-12-14 18:49     ` Oliver Kellogg
  0 siblings, 1 reply; 12+ messages in thread
From: Craig Carey @ 2003-12-14  1:50 UTC (permalink / raw)


On Sun, 14 Dec 2003 11:57:51 +1300, Craig Carey wrote:


>I uploaded a package that has merged Ada [A]Yacc parser lines.

I.e. SCATC and NewP2Ada got merged. If there is a version with fixess not
in those 2 then I would like to know of that.


>... has a demo program that makes [*use*] of the Adagoop program.
>   http://www.ijs.co.nz/code/ada95_adagoop_parser.zip


I get some of these wording errors out

>Two other document[*ed*] uses are [...]

I use Adagoopp and people at the USAFA use it. 

-------------

On 13 Dec 2003 17:46:17 +0100, Pascal Obry wrote:
...
>And if this version does not work you I have ported a version of aflex/ayacc
>(long time ago). You can download this from my homepage.
...
http://perso.wanadoo.fr/pascal.obry/archive/flexyacc.tar.gz
  "aflex/ayacc (9/3/1997)"

I guess that fixes in that gzip file are in NewP2Ada and my code.

Also it puts Ada code in case statement alternatives.

 * With case statement alternatives, the case alternative that sets a
   mode for a subexpression may be different from the case alternative
   that resets the mode.

   I don't know if changing the grammar can always provide a solution.

 * when Adagoop is used, probably recursion is used. So every mode that
   is set can be reset or unset. 

   E.g.  the quote in "x or '(0<a)" prevents the replacing of 'a' with
   its value.

Ada might have to be avoided if Yacc is not good enough, and debugging
Yacc is an area that could lead to a rejection of the Ada Yacc parser.

If YAcc was replaced with the moder advanced ANTLR C++ compiler, a
likely main problem could remain:

   http://www.bearcave.com/software/antlr/antlr_examples.html

  "I developed a "tiny C" grammar for ANTLR annotated to
   produce trees to better understand what a real ANTLR
   language front end would be like. One of the things that I
   learned with this grammar is that debugging ANTLR grammars
   is not that much easier than, say, debugging a YACC grammar.
   There was a mistake in the production describing the for-
   loop. ANTLR gave a non-determinism warning for the unary
   minus production. I spent hours pouring over my expression
   grammar containing the unary minus, but I could find no
   error in it."




Craig Carey



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Free Ada parser
  2003-12-14  1:50   ` Craig Carey
@ 2003-12-14 18:49     ` Oliver Kellogg
  2003-12-15 17:45       ` Robert I. Eachus
  0 siblings, 1 reply; 12+ messages in thread
From: Oliver Kellogg @ 2003-12-14 18:49 UTC (permalink / raw)


Craig Carey <research@ijs.co.nz> wrote in message news:<62gntvktko48ghlpls4ba46d4r0nh455ij@4ax.com>...
> 
> If YAcc was replaced with the moder advanced ANTLR C++ compiler, a
> likely main problem could remain:
> 
>   "I developed a "tiny C" grammar for ANTLR annotated to
>    produce trees to better understand what a real ANTLR
>    language front end would be like. One of the things that I
>    learned with this grammar is that debugging ANTLR grammars
>    is not that much easier than, say, debugging a YACC grammar.
>    There was a mistake in the production describing the for-
>    loop. ANTLR gave a non-determinism warning for the unary
>    minus production. I spent hours pouring over my expression
>    grammar containing the unary minus, but I could find no
>    error in it."

True, I had to resolve a couple of those ambiguities
while developing the ANTLR Ada grammar, but once you
really get into the ANTLR way of thinking it's not too bad.
Plus, this is a single-shot problem - it only affects the
development of the grammar itself but not its users.

--Oliver



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Free Ada parser
  2003-12-14 18:49     ` Oliver Kellogg
@ 2003-12-15 17:45       ` Robert I. Eachus
  0 siblings, 0 replies; 12+ messages in thread
From: Robert I. Eachus @ 2003-12-15 17:45 UTC (permalink / raw)




Oliver Kellogg wrote:

> True, I had to resolve a couple of those ambiguities
> while developing the ANTLR Ada grammar, but once you
> really get into the ANTLR way of thinking it's not too bad.
> Plus, this is a single-shot problem - it only affects the
> development of the grammar itself but not its users.

It is a property of writing grammars in general, doesn't matter how good 
the tools are.  If you write a grammar and it is say, LALR2 instead of 
LALR1, how likely is it that the tools can point to what you will think 
is the error?

Very unlikely of course.  The error that you made will almost certainly 
  be some production with a lookahead of one.  It is one or more 
potential prefixes of that production that will need to have a lookahead 
of two.

So when I am creating a grammar, I start with a 'skeleton' that has all 
the main features, then add details like identifier lists in object 
declarations.  Since I check the grammar after every extension, the 
problem must involve one of the productions I just added.


-- 
                                           Robert I. Eachus

100% Ada, no bugs--the only way to create software.




^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2003-12-15 17:45 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-09 18:10 Free Ada parser J Quirce
2003-12-09 19:27 ` David C. Hoos
2003-12-10 13:10   ` Oliver Kellogg
2003-12-10  8:11 ` Ole-Hjalmar Kristensen
2003-12-13 22:57 ` Craig Carey
2003-12-14  1:50   ` Craig Carey
2003-12-14 18:49     ` Oliver Kellogg
2003-12-15 17:45       ` Robert I. Eachus
  -- strict thread matches above, loose matches on Subject: below --
2003-12-11 14:50 ada_wizard
2003-12-12 21:05 ` Colin Paul Gloster
2003-12-13  3:02   ` Steve
2003-12-13 16:46     ` Pascal Obry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox