Ejemplo n.º 1
0
 internal Message(Token token, MessageType type, int pluralOrder)
 {
     Line = token.Line;
     Column = token.Column;
     Type = type;
     PluralOrder = pluralOrder;
 }
Ejemplo n.º 2
0
 internal Comment (Token.Comment comment)
 {
     Line = comment.Line;
     Column = comment.Column;
     Type = GetCommentType (comment.TypeChar);
     Value = comment.Value;
 }
Ejemplo n.º 3
0
 private Token Annotate(int line, int column, Token token)
 {
     token.Line = line;
     token.Column = column;
     return token;
 }
Ejemplo n.º 4
0
 private bool IsMsgstrToken (Token token)
 {
     return token is Token.Identifier && token.Value.StartsWith ("msgstr");
 }
Ejemplo n.º 5
0
 private bool IsStartOfUnitToken (Token token)
 {
     return token is Token.Comment ||
         (token is Token.Identifier &&
             (token.Value == "msgctxt" || token.Value == "msgid"));
 }
Ejemplo n.º 6
0
        private Message ParseIdentifier (Lexer lexer, Token.Identifier identifier)
        {
            var match = Regex.Match ((string)identifier, @"^msg(id|id_plural|str|str\[(\d+)\]|ctxt)$");
            if (!match.Success) {
                throw new SyntaxException (lexer, "invalid identifier: " + (string)identifier);
            }

            int plural_order;
            MessageType type;

            switch (match.Groups [1].Value) {
                case "id":
                    type = MessageType.SingularIdentifier;
                    plural_order = -1;
                    break;
                case "id_plural":
                    type = MessageType.PluralIdentifier;
                    plural_order = -1;
                    break;
                case "str":
                    type = MessageType.SingularString;
                    plural_order = 0;
                    break;
                case "ctxt":
                    type = MessageType.Context;
                    plural_order = -1;
                    break;
                default:
                    if (match.Groups.Count == 3) {
                        type = MessageType.PluralString;
                        plural_order = Int32.Parse (match.Groups [2].Value);
                    } else {
                        throw new SyntaxException(lexer, "invalid identifier: " + (string)identifier);
                    }
                    break;
            }

            return new Message (identifier, type, plural_order);
        }