Skip to content

Commit

Permalink
Fixes Object keyword not being considered to be an escaped type name. (
Browse files Browse the repository at this point in the history
…#42)

* Fixes Object keyword not being considered to be an escaped type name.

* Removed debug trace.

* Added scoped_name case.
  • Loading branch information
Luis Gasco authored Oct 13, 2020
1 parent 515e882 commit 69a469c
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/main/antlr4/omg/com/eprosima/idl/parser/grammar/IDL.g4
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,12 @@ scoped_name returns [Pair<String, Token> pair = null]
Token tk = _input.LT(1);
}
: ( {literalStr += _input.LT(1).getText();} DOUBLE_COLON )?
{literalStr += _input.LT(1).getText();} ID /* identifier */
( {literalStr += _input.LT(1).getText();} DOUBLE_COLON identifier { literalStr+=$identifier.id; } )*
{literalStr += _input.LT(1).getText();} (ID /* identifier */ | KW_OBJECT )
(
/* An escaped KW may be part of the scoped_name */
{literalStr += _input.LT(1).getText();} DOUBLE_COLON
(identifier { literalStr+=$identifier.id; } | KW_OBJECT { literalStr+="Object"; } )
)*
{$pair = new Pair<String, Token>(literalStr, tk);}
;

Expand Down Expand Up @@ -906,7 +910,7 @@ base_type_spec returns [TypeCode typecode = null]
| boolean_type { $typecode=$boolean_type.typecode; }
| octet_type { $typecode=$octet_type.typecode; }
| any_type
| object_type
| object_type { $typecode=$object_type.typecode; }
| value_base_type
;

Expand Down Expand Up @@ -1113,12 +1117,20 @@ any_type returns [TypeCode typecode]
: KW_ANY
;

object_type
object_type returns [TypeCode typecode]
@init{
Token tk = _input.LT(1);
}
: KW_OBJECT
{throw new ParseException(tk, ". Object type is not supported"); }
{
// Find typecode in the global map.
$typecode = ctx.getTypeCode("Object");
if($typecode == null)
{
throw new ParseException(tk, ". Object type is not supported");
}
}
;

annotation_decl returns [Pair<AnnotationDeclaration, TemplateGroup> returnPair = null]
Expand Down

0 comments on commit 69a469c

Please sign in to comment.