juneja-codebase 0.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- juneja_codebase-0.1.4/LICENSE +21 -0
- juneja_codebase-0.1.4/MANIFEST.in +3 -0
- juneja_codebase-0.1.4/PKG-INFO +75 -0
- juneja_codebase-0.1.4/README.md +57 -0
- juneja_codebase-0.1.4/juneja_codebase/__init__.py +6 -0
- juneja_codebase-0.1.4/juneja_codebase/main.py +197 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/compiler_design/AnshJuneja_Practical10_CD.l +15 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/compiler_design/AnshJuneja_Practical10_CD.y +27 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/compiler_design/AnshJuneja_Practical11_CD.l +15 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/compiler_design/AnshJuneja_Practical11_CD.y +36 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/compiler_design/AnshJuneja_Practical12_CD.l +14 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/compiler_design/AnshJuneja_Practical12_CD.y +31 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/compiler_design/AnshJuneja_Practical13_CD.l +14 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/compiler_design/AnshJuneja_Practical13_CD.y +38 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/compiler_design/AnshJuneja_Practical1_CD.l +38 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/compiler_design/AnshJuneja_Practical2_CD.l +27 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/compiler_design/AnshJuneja_Practical3_CD.l +39 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/compiler_design/AnshJuneja_Practical4_CD.l +32 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/compiler_design/AnshJuneja_Practical5_CD.l +51 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/compiler_design/AnshJuneja_Practical6_CD.l +46 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/compiler_design/AnshJuneja_Practical7_CD.l +36 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/compiler_design/AnshJuneja_Practical8_CD.l +33 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/compiler_design/AnshJuneja_Practical9_CD.l +19 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/compiler_design/AnshJuneja_Practical9_CD.y +36 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/social_network_analysis/1_try.ipynb +286 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/social_network_analysis/2_try.ipynb +352 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/social_network_analysis/3_try.ipynb +207 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/social_network_analysis/4_try.ipynb +1218 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/social_network_analysis/5_try.ipynb +326 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/social_network_analysis/6_try.ipynb +241 -0
- juneja_codebase-0.1.4/juneja_codebase/templates/social_network_analysis/new.ipynb +592 -0
- juneja_codebase-0.1.4/juneja_codebase.egg-info/PKG-INFO +75 -0
- juneja_codebase-0.1.4/juneja_codebase.egg-info/SOURCES.txt +37 -0
- juneja_codebase-0.1.4/juneja_codebase.egg-info/dependency_links.txt +1 -0
- juneja_codebase-0.1.4/juneja_codebase.egg-info/entry_points.txt +3 -0
- juneja_codebase-0.1.4/juneja_codebase.egg-info/top_level.txt +1 -0
- juneja_codebase-0.1.4/setup.cfg +15 -0
- juneja_codebase-0.1.4/setup.py +29 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 AJ
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: juneja_codebase
|
|
3
|
+
Version: 0.1.4
|
|
4
|
+
Summary: CLI tool to generate academic practical code files for Compiler Design, Data Structures, OS, and DBMS
|
|
5
|
+
Home-page: UNKNOWN
|
|
6
|
+
Author: AJ
|
|
7
|
+
License: UNKNOWN
|
|
8
|
+
Platform: UNKNOWN
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Intended Audience :: Education
|
|
13
|
+
Requires-Python: >=3.6
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
|
|
17
|
+
# reqcode-aj
|
|
18
|
+
|
|
19
|
+
A Python CLI tool to generate academic practical code files offline.
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install reqcode-aj
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Standard Method
|
|
30
|
+
```bash
|
|
31
|
+
# List available subjects
|
|
32
|
+
reqcode --list
|
|
33
|
+
|
|
34
|
+
# Generate all code files
|
|
35
|
+
reqcode --all
|
|
36
|
+
|
|
37
|
+
# Generate specific subject
|
|
38
|
+
reqcode --subject compiler_design
|
|
39
|
+
|
|
40
|
+
# Save to specific directory
|
|
41
|
+
reqcode --all --output ./my_codes
|
|
42
|
+
|
|
43
|
+
# Create zip file
|
|
44
|
+
reqcode --all --zip
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Alternative Method (Use this in lab/college systems if `reqcode` command doesn't work)
|
|
48
|
+
```bash
|
|
49
|
+
# If you get "command not found" or "not recognized" error, use:
|
|
50
|
+
python -m reqcode_aj.main --list
|
|
51
|
+
python -m reqcode_aj.main --all
|
|
52
|
+
python -m reqcode_aj.main --subject compiler_design
|
|
53
|
+
python -m reqcode_aj.main --all --zip
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Note:** The alternative method works on ALL systems and doesn't require the Scripts folder to be in PATH.
|
|
57
|
+
|
|
58
|
+
## Subjects Included
|
|
59
|
+
|
|
60
|
+
1. **Compiler Design** - Lex and Yacc practical files
|
|
61
|
+
2. **Deep Learning** - Deep learning implementations
|
|
62
|
+
3. **Social Network Analysis** - Network analysis code
|
|
63
|
+
|
|
64
|
+
## Features
|
|
65
|
+
|
|
66
|
+
- Works completely offline
|
|
67
|
+
- All practical files bundled in the package
|
|
68
|
+
- Perfect for lab practicals and exam preparation
|
|
69
|
+
- No internet required after installation
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
MIT License
|
|
74
|
+
|
|
75
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# reqcode-aj
|
|
2
|
+
|
|
3
|
+
A Python CLI tool to generate academic practical code files offline.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install reqcode-aj
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Standard Method
|
|
14
|
+
```bash
|
|
15
|
+
# List available subjects
|
|
16
|
+
reqcode --list
|
|
17
|
+
|
|
18
|
+
# Generate all code files
|
|
19
|
+
reqcode --all
|
|
20
|
+
|
|
21
|
+
# Generate specific subject
|
|
22
|
+
reqcode --subject compiler_design
|
|
23
|
+
|
|
24
|
+
# Save to specific directory
|
|
25
|
+
reqcode --all --output ./my_codes
|
|
26
|
+
|
|
27
|
+
# Create zip file
|
|
28
|
+
reqcode --all --zip
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Alternative Method (Use this in lab/college systems if `reqcode` command doesn't work)
|
|
32
|
+
```bash
|
|
33
|
+
# If you get "command not found" or "not recognized" error, use:
|
|
34
|
+
python -m reqcode_aj.main --list
|
|
35
|
+
python -m reqcode_aj.main --all
|
|
36
|
+
python -m reqcode_aj.main --subject compiler_design
|
|
37
|
+
python -m reqcode_aj.main --all --zip
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Note:** The alternative method works on ALL systems and doesn't require the Scripts folder to be in PATH.
|
|
41
|
+
|
|
42
|
+
## Subjects Included
|
|
43
|
+
|
|
44
|
+
1. **Compiler Design** - Lex and Yacc practical files
|
|
45
|
+
2. **Deep Learning** - Deep learning implementations
|
|
46
|
+
3. **Social Network Analysis** - Network analysis code
|
|
47
|
+
|
|
48
|
+
## Features
|
|
49
|
+
|
|
50
|
+
- Works completely offline
|
|
51
|
+
- All practical files bundled in the package
|
|
52
|
+
- Perfect for lab practicals and exam preparation
|
|
53
|
+
- No internet required after installation
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT License
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Main CLI entry point for reqcode-aj
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import argparse
|
|
7
|
+
import os
|
|
8
|
+
import shutil
|
|
9
|
+
import zipfile
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def get_templates_dir():
|
|
14
|
+
"""Get the path to the templates directory"""
|
|
15
|
+
return Path(__file__).parent / "templates"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def list_subjects():
|
|
19
|
+
"""List all available subjects"""
|
|
20
|
+
templates_dir = get_templates_dir()
|
|
21
|
+
subjects = [d.name for d in templates_dir.iterdir() if d.is_dir()]
|
|
22
|
+
return subjects
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def copy_subject_files(subject, output_dir):
|
|
26
|
+
"""Copy files for a specific subject to the output directory"""
|
|
27
|
+
templates_dir = get_templates_dir()
|
|
28
|
+
subject_dir = templates_dir / subject
|
|
29
|
+
|
|
30
|
+
if not subject_dir.exists():
|
|
31
|
+
print(f"Error: Subject '{subject}' not found!")
|
|
32
|
+
print(f"Available subjects: {', '.join(list_subjects())}")
|
|
33
|
+
return False
|
|
34
|
+
|
|
35
|
+
output_path = Path(output_dir) / subject
|
|
36
|
+
output_path.mkdir(parents=True, exist_ok=True)
|
|
37
|
+
|
|
38
|
+
# Copy all files from subject directory
|
|
39
|
+
for item in subject_dir.rglob('*'):
|
|
40
|
+
if item.is_file():
|
|
41
|
+
relative_path = item.relative_to(subject_dir)
|
|
42
|
+
dest_path = output_path / relative_path
|
|
43
|
+
dest_path.parent.mkdir(parents=True, exist_ok=True)
|
|
44
|
+
shutil.copy2(item, dest_path)
|
|
45
|
+
print(f"Created: {dest_path}")
|
|
46
|
+
|
|
47
|
+
return True
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def copy_all_subjects(output_dir):
|
|
51
|
+
"""Copy files for all subjects to the output directory"""
|
|
52
|
+
subjects = list_subjects()
|
|
53
|
+
success = True
|
|
54
|
+
|
|
55
|
+
for subject in subjects:
|
|
56
|
+
print(f"\n=== Generating {subject} files ===")
|
|
57
|
+
if not copy_subject_files(subject, output_dir):
|
|
58
|
+
success = False
|
|
59
|
+
|
|
60
|
+
return success
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def create_zip_archive(subject, output_file):
|
|
64
|
+
"""Create a zip archive for a specific subject or all subjects"""
|
|
65
|
+
templates_dir = get_templates_dir()
|
|
66
|
+
|
|
67
|
+
if subject:
|
|
68
|
+
# Zip specific subject
|
|
69
|
+
subject_dir = templates_dir / subject
|
|
70
|
+
if not subject_dir.exists():
|
|
71
|
+
print(f"Error: Subject '{subject}' not found!")
|
|
72
|
+
return False
|
|
73
|
+
|
|
74
|
+
zip_name = output_file if output_file else f"{subject}.zip"
|
|
75
|
+
|
|
76
|
+
with zipfile.ZipFile(zip_name, 'w', zipfile.ZIP_DEFLATED) as zipf:
|
|
77
|
+
for item in subject_dir.rglob('*'):
|
|
78
|
+
if item.is_file():
|
|
79
|
+
arcname = subject / item.relative_to(subject_dir)
|
|
80
|
+
zipf.write(item, arcname)
|
|
81
|
+
print(f"Added to zip: {arcname}")
|
|
82
|
+
|
|
83
|
+
print(f"\n✓ Created zip file: {zip_name}")
|
|
84
|
+
return True
|
|
85
|
+
else:
|
|
86
|
+
# Zip all subjects
|
|
87
|
+
zip_name = output_file if output_file else "all_subjects.zip"
|
|
88
|
+
|
|
89
|
+
with zipfile.ZipFile(zip_name, 'w', zipfile.ZIP_DEFLATED) as zipf:
|
|
90
|
+
for subject_dir in templates_dir.iterdir():
|
|
91
|
+
if subject_dir.is_dir():
|
|
92
|
+
print(f"\nAdding {subject_dir.name} to zip...")
|
|
93
|
+
for item in subject_dir.rglob('*'):
|
|
94
|
+
if item.is_file():
|
|
95
|
+
arcname = item.relative_to(templates_dir)
|
|
96
|
+
zipf.write(item, arcname)
|
|
97
|
+
print(f"Added: {arcname}")
|
|
98
|
+
|
|
99
|
+
print(f"\n✓ Created zip file: {zip_name}")
|
|
100
|
+
return True
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def main():
|
|
104
|
+
"""Main entry point for the CLI"""
|
|
105
|
+
parser = argparse.ArgumentParser(
|
|
106
|
+
description="Generate code files for academic practicals",
|
|
107
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
108
|
+
epilog="""
|
|
109
|
+
Examples:
|
|
110
|
+
reqcode --list # List available subjects
|
|
111
|
+
reqcode --all # Generate all code files
|
|
112
|
+
reqcode --subject compiler_design # Generate specific subject files
|
|
113
|
+
reqcode --all --output ./my_codes # Generate to specific directory
|
|
114
|
+
reqcode --all --zip # Create zip of all subjects
|
|
115
|
+
reqcode --subject compiler_design --zip # Create zip of specific subject
|
|
116
|
+
"""
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
parser.add_argument(
|
|
120
|
+
'--list', '-l',
|
|
121
|
+
action='store_true',
|
|
122
|
+
help='List all available subjects'
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
parser.add_argument(
|
|
126
|
+
'--all', '-a',
|
|
127
|
+
action='store_true',
|
|
128
|
+
help='Generate code files for all subjects'
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
parser.add_argument(
|
|
132
|
+
'--subject', '-s',
|
|
133
|
+
type=str,
|
|
134
|
+
help='Generate code files for a specific subject'
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
parser.add_argument(
|
|
138
|
+
'--output', '-o',
|
|
139
|
+
type=str,
|
|
140
|
+
default='.',
|
|
141
|
+
help='Output directory or zip filename (default: current directory)'
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
parser.add_argument(
|
|
145
|
+
'--zip', '-z',
|
|
146
|
+
action='store_true',
|
|
147
|
+
help='Create a zip file instead of extracting files'
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
parser.add_argument(
|
|
151
|
+
'--version', '-v',
|
|
152
|
+
action='version',
|
|
153
|
+
version='%(prog)s 0.1.0'
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
args = parser.parse_args()
|
|
157
|
+
|
|
158
|
+
# List subjects
|
|
159
|
+
if args.list:
|
|
160
|
+
subjects = list_subjects()
|
|
161
|
+
print("Available subjects:")
|
|
162
|
+
for i, subject in enumerate(subjects, 1):
|
|
163
|
+
print(f" {i}. {subject}")
|
|
164
|
+
return
|
|
165
|
+
|
|
166
|
+
# Create zip archive
|
|
167
|
+
if args.zip:
|
|
168
|
+
if args.all:
|
|
169
|
+
create_zip_archive(None, args.output if args.output != '.' else None)
|
|
170
|
+
elif args.subject:
|
|
171
|
+
create_zip_archive(args.subject, args.output if args.output != '.' else None)
|
|
172
|
+
else:
|
|
173
|
+
print("Error: Please specify --all or --subject with --zip")
|
|
174
|
+
parser.print_help()
|
|
175
|
+
return
|
|
176
|
+
|
|
177
|
+
# Generate files
|
|
178
|
+
if args.all:
|
|
179
|
+
print("Generating all subject files...")
|
|
180
|
+
copy_all_subjects(args.output)
|
|
181
|
+
print(f"\n✓ All files generated in: {os.path.abspath(args.output)}")
|
|
182
|
+
elif args.subject:
|
|
183
|
+
print(f"Generating {args.subject} files...")
|
|
184
|
+
copy_subject_files(args.subject, args.output)
|
|
185
|
+
print(f"\n✓ Files generated in: {os.path.abspath(args.output)}")
|
|
186
|
+
else:
|
|
187
|
+
# No action specified, show help
|
|
188
|
+
parser.print_help()
|
|
189
|
+
print("\n" + "="*70)
|
|
190
|
+
print("💡 TIP: If 'reqcode' command doesn't work in your system, use:")
|
|
191
|
+
print(" python -m reqcode_aj.main --list")
|
|
192
|
+
print(" python -m reqcode_aj.main --all")
|
|
193
|
+
print("="*70)
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
if __name__ == '__main__':
|
|
197
|
+
main()
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
%{
|
|
2
|
+
#include <stdio.h>
|
|
3
|
+
#include <stdlib.h>
|
|
4
|
+
|
|
5
|
+
int yylex();
|
|
6
|
+
int yyerror(const char *s);
|
|
7
|
+
%}
|
|
8
|
+
|
|
9
|
+
%token LETTER DIGIT
|
|
10
|
+
|
|
11
|
+
%%
|
|
12
|
+
|
|
13
|
+
S : LETTER DIGIT '\n' { printf("Valid variable\n"); }
|
|
14
|
+
;
|
|
15
|
+
|
|
16
|
+
%%
|
|
17
|
+
|
|
18
|
+
int yyerror(const char *s) {
|
|
19
|
+
printf("Invalid variable\n");
|
|
20
|
+
return 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
int main() {
|
|
24
|
+
printf("Enter variable: ");
|
|
25
|
+
yyparse();
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
%{
|
|
2
|
+
#include <stdio.h>
|
|
3
|
+
#include <stdlib.h>
|
|
4
|
+
|
|
5
|
+
int yylex();
|
|
6
|
+
int yyerror(const char *s);
|
|
7
|
+
%}
|
|
8
|
+
|
|
9
|
+
%token NUM
|
|
10
|
+
%left '+' '-'
|
|
11
|
+
%left '*' '/'
|
|
12
|
+
|
|
13
|
+
%%
|
|
14
|
+
|
|
15
|
+
S : E '\n' { printf("Result = %d\n", $1); }
|
|
16
|
+
;
|
|
17
|
+
|
|
18
|
+
E : E '+' E { $$ = $1 + $3; }
|
|
19
|
+
| E '-' E { $$ = $1 - $3; }
|
|
20
|
+
| E '*' E { $$ = $1 * $3; }
|
|
21
|
+
| E '/' E { $$ = $1 / $3; }
|
|
22
|
+
| NUM { $$ = $1; }
|
|
23
|
+
;
|
|
24
|
+
|
|
25
|
+
%%
|
|
26
|
+
|
|
27
|
+
int yyerror(const char *s) {
|
|
28
|
+
printf("Invalid expression\n");
|
|
29
|
+
return 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
int main() {
|
|
33
|
+
printf("Enter expression:\n");
|
|
34
|
+
yyparse();
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
%{
|
|
2
|
+
#include <stdio.h>
|
|
3
|
+
#include <stdlib.h>
|
|
4
|
+
|
|
5
|
+
int yylex();
|
|
6
|
+
int yyerror(const char *s);
|
|
7
|
+
%}
|
|
8
|
+
|
|
9
|
+
%token A B
|
|
10
|
+
|
|
11
|
+
%%
|
|
12
|
+
|
|
13
|
+
S : A BPLUS '\n' { printf("Valid string\n"); }
|
|
14
|
+
;
|
|
15
|
+
|
|
16
|
+
BPLUS : B
|
|
17
|
+
| B BPLUS
|
|
18
|
+
;
|
|
19
|
+
|
|
20
|
+
%%
|
|
21
|
+
|
|
22
|
+
int yyerror(const char *s) {
|
|
23
|
+
printf("Invalid string\n");
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
int main() {
|
|
28
|
+
printf("Enter string: ");
|
|
29
|
+
yyparse();
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
%{
|
|
2
|
+
#include <stdio.h>
|
|
3
|
+
#include <stdlib.h>
|
|
4
|
+
|
|
5
|
+
int yylex();
|
|
6
|
+
int yyerror(const char *s);
|
|
7
|
+
int count = 0;
|
|
8
|
+
%}
|
|
9
|
+
|
|
10
|
+
%token A B
|
|
11
|
+
|
|
12
|
+
%%
|
|
13
|
+
|
|
14
|
+
S : ALIST B '\n'
|
|
15
|
+
{
|
|
16
|
+
if (count >= 1)
|
|
17
|
+
printf("Valid string\n");
|
|
18
|
+
else
|
|
19
|
+
printf("Invalid string\n");
|
|
20
|
+
}
|
|
21
|
+
;
|
|
22
|
+
|
|
23
|
+
ALIST : A { count++; }
|
|
24
|
+
| ALIST A { count++; }
|
|
25
|
+
;
|
|
26
|
+
|
|
27
|
+
%%
|
|
28
|
+
|
|
29
|
+
int yyerror(const char *s) {
|
|
30
|
+
printf("Invalid string\n");
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
int main() {
|
|
35
|
+
printf("Enter string: ");
|
|
36
|
+
yyparse();
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
%{
|
|
2
|
+
#include <stdio.h>
|
|
3
|
+
#include <ctype.h>
|
|
4
|
+
int charCount = 0;
|
|
5
|
+
int lineCount = 1;
|
|
6
|
+
int numCount = 0;
|
|
7
|
+
int special = 0;
|
|
8
|
+
%}
|
|
9
|
+
|
|
10
|
+
%%
|
|
11
|
+
[\n] lineCount++; printf("%c" , yytext[0]);
|
|
12
|
+
[a-zA-Z] charCount++; printf("%c", yytext[0]);
|
|
13
|
+
[0-9] numCount++; printf("%c" , yytext[0]);
|
|
14
|
+
[@#$%*<:>;&^!()_+=|\~`{}] special = 1; printf("%c" , yytext[0]);
|
|
15
|
+
|
|
16
|
+
%%
|
|
17
|
+
int yywrap(){
|
|
18
|
+
return 1;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
int main(int argc, char* argv[]){
|
|
22
|
+
|
|
23
|
+
yyin = fopen("input.txt", "r");
|
|
24
|
+
yyout = fopen("output.txt", "w");
|
|
25
|
+
|
|
26
|
+
yylex();
|
|
27
|
+
|
|
28
|
+
fprintf(yyout,"Line Count %d\n ", lineCount);
|
|
29
|
+
fprintf(yyout,"Character Count %d\n ", charCount);
|
|
30
|
+
fprintf(yyout,"Number Count %d\n ", numCount);
|
|
31
|
+
if (special==1)fprintf(yyout,"Special: True\n");
|
|
32
|
+
else fprintf(yyout,"Special: False\n");
|
|
33
|
+
|
|
34
|
+
fclose(yyin);
|
|
35
|
+
fclose(yyout);
|
|
36
|
+
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
%{
|
|
2
|
+
#include<stdio.h>
|
|
3
|
+
#include<ctype.h>
|
|
4
|
+
int vowelcnt = 0;
|
|
5
|
+
int constcnt = 0;
|
|
6
|
+
%}
|
|
7
|
+
|
|
8
|
+
%%
|
|
9
|
+
[aeiouAEIOU] vowelcnt++;
|
|
10
|
+
[a-zA-Z] constcnt++;
|
|
11
|
+
|
|
12
|
+
%%
|
|
13
|
+
int yywrap() {
|
|
14
|
+
return 1;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
int main(){
|
|
18
|
+
|
|
19
|
+
yylex();
|
|
20
|
+
|
|
21
|
+
printf("vowel count : %d\n",vowelcnt);
|
|
22
|
+
printf("Consonant Count : %d\n", constcnt);
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
return 0;
|
|
26
|
+
|
|
27
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
%{
|
|
2
|
+
#include <stdio.h>
|
|
3
|
+
#include <ctype.h>
|
|
4
|
+
|
|
5
|
+
char shift_char(char c) {
|
|
6
|
+
if (c >= 'a' && c <= 'z') {
|
|
7
|
+
return 'a' + ( (c - 'a' + 3) % 26 );
|
|
8
|
+
}
|
|
9
|
+
else if (c >= 'A' && c <= 'Z') {
|
|
10
|
+
return 'A' + ( (c - 'A' + 3) % 26 );
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
return c;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
%}
|
|
17
|
+
|
|
18
|
+
%%
|
|
19
|
+
[a-zA-Z] {
|
|
20
|
+
char c = yytext[0];
|
|
21
|
+
c = shift_char(c);
|
|
22
|
+
printf("%c", c);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.|\n {
|
|
26
|
+
printf("%s", yytext);
|
|
27
|
+
}
|
|
28
|
+
%%
|
|
29
|
+
|
|
30
|
+
int yywrap() {
|
|
31
|
+
return 1;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
int main() {
|
|
35
|
+
|
|
36
|
+
yylex();
|
|
37
|
+
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
%{
|
|
2
|
+
#include <stdio.h>
|
|
3
|
+
#include <ctype.h>
|
|
4
|
+
#include <string.h>
|
|
5
|
+
char longestWord[1000];
|
|
6
|
+
%}
|
|
7
|
+
|
|
8
|
+
%%
|
|
9
|
+
[A-Za-z]+ {
|
|
10
|
+
if (strlen(yytext) > strlen(longestWord)){
|
|
11
|
+
strcpy(longestWord, yytext);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
%%
|
|
18
|
+
|
|
19
|
+
int yywrap(){
|
|
20
|
+
return 1;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
int main(){
|
|
24
|
+
yylex();
|
|
25
|
+
if(strlen(longestWord) > 0)
|
|
26
|
+
printf("Longest word: %s\n", longestWord);
|
|
27
|
+
else
|
|
28
|
+
printf("No words found \n");
|
|
29
|
+
|
|
30
|
+
return 0;
|
|
31
|
+
|
|
32
|
+
}
|