~sandy-dunlop/wildcatcobol/dev

« back to all changes in this revision

Viewing changes to src/Wildcat.Cobol.Compiler/Parser/Parser.cs

  • Committer: Sandy Dunlop
  • Date: 2007-10-14 16:14:53 UTC
  • mfrom: (7.1.5 filewrite)
  • Revision ID: sandy.dunlop@gmail.com-20071014161453-otgf2yviplpqbviq
Merging from filewrite branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
455
455
            if (_tokenizer.Accept(SymType.Dot))
456
456
            {
457
457
                //This is a group item, rather than an elementary item
458
 
                data.IsGroup = true;
 
458
                data.IsGroup = true;
 
459
                data.Type = DataType.String;
459
460
//=============================================================================
460
461
                //ws.DataDescriptions.Add(data);
461
462
                if (data.Name!=null){
775
776
                literal.Value = " ";
776
777
                source = literal as Source;
777
778
            }
778
 
            else if (_tokenizer.Accept(SymType.Spaces))
779
 
            {
780
 
                source = new Source();
781
 
                source.IsSpaces = true;
782
 
            }
783
779
            else if (_tokenizer.Accept(SymType.Zero))
784
780
            {
785
781
                Literal literal = new Literal();
788
784
                source = literal as Source;
789
785
            }
790
786
            else
791
 
            {
792
 
                source = ParseLiteral() as Source;
793
 
                if (source == null)
 
787
            {
 
788
                source = ParseFigurativeConstant() as Source;
 
789
                if (source == null)
794
790
                {
795
 
                    source = ParseIdentifier() as Source;
 
791
                    source = ParseLiteral() as Source;
796
792
                    if (source == null)
797
 
                        return null;
798
 
                    source.LineNumber = _tokenizer.LineNumber;
799
 
                    //TODO: Fix this
800
 
//                      if (_tokenizer.Accept(SymType.Delimited))
801
 
//                      {
802
 
//                              Console.WriteLine("*** PARSING DELIMITED ***");
803
 
//                          Identifier iden = source as Identifier;
804
 
//                              _tokenizer.Accept(SymType.By);//optional BY
805
 
//                              iden.Delimiter = ParseSource();
806
 
//                      }
 
793
                    {
 
794
                        source = ParseIdentifier() as Source;
 
795
                        if (source == null)
 
796
                            return null;
 
797
                        source.LineNumber = _tokenizer.LineNumber;
 
798
//                      TODO: Fix this
 
799
//                      if (_tokenizer.Accept(SymType.Delimited))
 
800
//                      {
 
801
//                              Console.WriteLine("*** PARSING DELIMITED ***");
 
802
//                          Identifier iden = source as Identifier;
 
803
//                              _tokenizer.Accept(SymType.By);//optional BY
 
804
//                              iden.Delimiter = ParseSource();
 
805
//                      }
 
806
                    }
807
807
                }
808
808
            }
809
 
            if (source.GetType() == typeof(Identifier))
810
 
            {
811
 
                Identifier id = source as Identifier;
812
 
            }
 
809
//            if (source.GetType() == typeof(Identifier))
 
810
//            {
 
811
//              Identifier id = source as Identifier;
 
812
//            }
813
813
            if (goBackOnDot==true && source!=null && _tokenizer.CurrentSymbol!=null && _tokenizer.CurrentSymbol.Type == SymType.Dot)
814
814
            {
815
815
                _tokenizer.RestorePosition();
823
823
                _ast.VariableReferences.Add(source);                    
824
824
            }
825
825
                        return source;
 
826
                }
 
827
                
 
828
                private FigurativeConstant ParseFigurativeConstant()
 
829
                {
 
830
                    FigurativeConstant fc = new FigurativeConstant();
 
831
            if (_tokenizer.Accept(SymType.Spaces))
 
832
            {
 
833
                fc.Type = FigurativeConstantType.Spaces;
 
834
                return fc;
 
835
            }else{
 
836
                return null;
 
837
            }
826
838
                }
827
839
                
828
840
                private ProcedureDivision ParseProcedureDivision()
1085
1097
                WriteStatement writeStatement = new WriteStatement();
1086
1098
                //TODO: More complex versions of WRITE
1087
1099
            writeStatement.RecordName = ParseIdentifier();
 
1100
            _ast.VariableReferences.Add(writeStatement.RecordName);
1088
1101
                if (_tokenizer.Accept(SymType.From))
1089
1102
                {
1090
1103
                    writeStatement.From = ParseIdentifier();
 
1104
                _ast.VariableReferences.Add(writeStatement.From);
1091
1105
                }
1092
1106
                _tokenizer.Accept(SymType.EndWrite);
1093
1107
                return writeStatement;