Skip to content

Commit

Permalink
Merge pull request #325 from ros2/idl-stage-4
Browse files Browse the repository at this point in the history
add lark-based grammar
  • Loading branch information
dirk-thomas authored Nov 15, 2018
2 parents c2fed92 + 8a2e80d commit 83baf3c
Show file tree
Hide file tree
Showing 2 changed files with 566 additions and 0 deletions.
48 changes: 48 additions & 0 deletions rosidl_parser/rosidl_parser/common.lark
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// Numbers
//

DIGIT: "0".."9"
HEXDIGIT: "a".."f"|"A".."F"|DIGIT

INT: DIGIT+
SIGNED_INT: ["+"|"-"] INT
DECIMAL: INT "." INT? | "." INT

// float = /-?\d+(\.\d+)?([eE][+-]?\d+)?/
_EXP: ("e"|"E") SIGNED_INT
FLOAT: INT _EXP | DECIMAL _EXP?
SIGNED_FLOAT: ["+"|"-"] FLOAT

NUMBER: FLOAT | INT
SIGNED_NUMBER: ["+"|"-"] NUMBER

//
// Strings
//
//STRING: /"(\\\"|\\\\|[^"\n])*?"i?/
STRING_INNER: ("\\\""|/[^"]/)
ESCAPED_STRING: "\"" STRING_INNER* "\""


//
// Names (Variables)
//
LCASE_LETTER: "a".."z"
UCASE_LETTER: "A".."Z"

LETTER: UCASE_LETTER | LCASE_LETTER
WORD: LETTER+

CNAME: ("_"|LETTER) ("_"|LETTER|DIGIT)*


//
// Whitespace
//
WS_INLINE: (" "|/\t/)+
WS: /[ \t\f\r\n]/+

CR : /\r/
LF : /\n/
NEWLINE: (CR? LF)+
Loading

0 comments on commit 83baf3c

Please sign in to comment.