Example #1
0
        private IEnumerable <PoUnit> ParseAllTokenStreams()
        {
            foreach (var path in po_paths)
            {
                var       unit    = new PoUnit();
                PoMessage message = null;

                using (var reader = new StreamReader(path)) {
                    var lexer = new PoLexer {
                        Path   = path,
                        Reader = reader
                    };

                    foreach (var token in lexer.Lex())
                    {
                        if (token is PoLexer.Token.Comment)
                        {
                            unit.Comments.Add((PoLexer.Token.Comment)token);
                        }
                        else if (token is PoLexer.Token.Identifier)
                        {
                            message = new PoMessage {
                                Identifier = (string)token
                            };
                            unit.Messages.Add(message);
                        }
                        else if (token is PoLexer.Token.String)
                        {
                            message.Value += (string)token;
                        }
                        else if (token is PoLexer.Token.EndOfUnit)
                        {
                            yield return(unit);

                            unit = new PoUnit();
                        }
                    }
                }

                yield return(unit);
            }
        }
Example #2
0
 public SyntaxException(PoLexer lexer, string message)
     : base(String.Format ("Syntax error: \"{0}\": {1}:{2},{3} ('{4}')",
         message, lexer.Path, lexer.Line, lexer.Column, lexer.Peek ()))
 {
 }
Example #3
0
 public SyntaxException(PoLexer lexer, string message)
     : base(String.Format("Syntax error: \"{0}\": {1}:{2},{3} ('{4}')",
                          message, lexer.Path, lexer.Line, lexer.Column, lexer.Peek()))
 {
 }