curl-programming-lang 1.4.1__tar.gz → 1.4.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: curl-programming-lang
3
- Version: 1.4.1
3
+ Version: 1.4.2
4
4
  Summary: Curl is an open-source programming language built on Python technology
5
5
  Author: Ritvik Gautam
6
6
  License: Apache-2.0
@@ -47,9 +47,10 @@ git clone https://github.com/gautamritvik/Curl-Programming.git
47
47
  cd Curl-Programming
48
48
  pip install -e .
49
49
  ```
50
+
50
51
  ---
51
52
 
52
- ## Running the Curl terminal
53
+ ## Running the Curl terminal (REPL)
53
54
 
54
55
  ```
55
56
  curlang
@@ -61,6 +62,15 @@ curlang
61
62
  curlang [YOUR-FILE].curl
62
63
  ```
63
64
 
65
+ ## CLI flags
66
+
67
+ ```
68
+ curlang --version show version
69
+ curlang --license show license
70
+ curlang --credits show credits
71
+ curlang --help show help
72
+ ```
73
+
64
74
  ---
65
75
 
66
76
  ## Syntax Reference
@@ -81,7 +91,7 @@ pcType{"Hello, " + var{name} + "!"}\
81
91
  Prompts the user for input. The result is accessed anywhere with `input{ans}`.
82
92
 
83
93
  ```
84
- pcAsk{"What is your name?">>}\
94
+ pcAsk{"What is your name? >>"}\
85
95
  pcType{"You said: " + input{ans}}\
86
96
  ```
87
97
 
@@ -198,12 +208,51 @@ import{"math", m}\
198
208
 
199
209
  ### AI — `pcAI`
200
210
 
201
- *(Stubreserved for future AI integration.)*
211
+ `pcAI` is a **built-in AI module** no import required. It supports conversation history, system prompts, and an interactive chat mode.
212
+
213
+ Configure it with environment variables:
214
+
215
+ | Variable | Default | Description |
216
+ |---|---|---|
217
+ | `CURL_AI_KEY` or `OPENAI_API_KEY` | *(none)* | Your API key |
218
+ | `CURL_AI_BASE_URL` | `https://api.openai.com/v1` | API base URL |
219
+ | `CURL_AI_MODEL` | `gpt-4o-mini` | Model name |
220
+
221
+ Works with **OpenAI**, **OpenRouter**, **Ollama**, or any OpenAI-compatible API.
222
+
223
+ **Ask a question:**
224
+
225
+ ```
226
+ var{reply, pcAI.ask{"What is the capital of France?"}}\
227
+ pcType{var{reply}}\
228
+ ```
229
+
230
+ **Set a persona (system prompt):**
231
+
232
+ ```
233
+ pcAI.context{"You are a friendly pirate who answers in rhymes."}\
234
+ var{reply, pcAI.ask{"What is 2 + 2?"}}\
235
+ pcType{var{reply}}\
236
+ ```
237
+
238
+ **Interactive chat loop** (type `exit` to quit):
239
+
240
+ ```
241
+ pcAI.chat{""}\
242
+ ```
243
+
244
+ **Other methods:**
202
245
 
203
246
  ```
204
- pcAI{".on", "You are a helpful assistant", "profanityControl"}\
247
+ var{s, pcAI.summarize{"some long text"}}\
248
+ var{a, pcAI.analyze{"some data"}}\
249
+ var{mood, pcAI.sentiment{"I love this!"}}\
250
+ var{t, pcAI.translate{"Bonjour — translate to English"}}\
251
+ pcAI.reset{""}\
205
252
  ```
206
253
 
254
+ > Conversation history is kept across `pcAI.ask` calls and auto-compacts when it gets long.
255
+
207
256
  ---
208
257
 
209
258
  ## Symbols
@@ -221,6 +270,9 @@ pcAI{".on", "You are a helpful assistant", "profanityControl"}\
221
270
  | `!=` | Not equals |
222
271
  | `=` | Assignment |
223
272
  | `+` | Concatenation / addition |
273
+ | `-` | Subtraction |
274
+ | `*` | Multiplication |
275
+ | `/` | Division |
224
276
 
225
277
  ---
226
278
 
@@ -246,6 +298,16 @@ func{sayBye}\
246
298
 
247
299
  ---
248
300
 
301
+ ## Example AI program
302
+
303
+ ```
304
+ pcAI.context{"You are a helpful tutor."}\
305
+ var{answer, pcAI.ask{"Explain what a variable is in one sentence."}}\
306
+ pcType{var{answer}}\
307
+ ```
308
+
309
+ ---
310
+
249
311
  ## License
250
312
 
251
313
  This project is licensed under the Apache License 2.0 (OSI-approved).
@@ -28,9 +28,10 @@ git clone https://github.com/gautamritvik/Curl-Programming.git
28
28
  cd Curl-Programming
29
29
  pip install -e .
30
30
  ```
31
+
31
32
  ---
32
33
 
33
- ## Running the Curl terminal
34
+ ## Running the Curl terminal (REPL)
34
35
 
35
36
  ```
36
37
  curlang
@@ -42,6 +43,15 @@ curlang
42
43
  curlang [YOUR-FILE].curl
43
44
  ```
44
45
 
46
+ ## CLI flags
47
+
48
+ ```
49
+ curlang --version show version
50
+ curlang --license show license
51
+ curlang --credits show credits
52
+ curlang --help show help
53
+ ```
54
+
45
55
  ---
46
56
 
47
57
  ## Syntax Reference
@@ -62,7 +72,7 @@ pcType{"Hello, " + var{name} + "!"}\
62
72
  Prompts the user for input. The result is accessed anywhere with `input{ans}`.
63
73
 
64
74
  ```
65
- pcAsk{"What is your name?">>}\
75
+ pcAsk{"What is your name? >>"}\
66
76
  pcType{"You said: " + input{ans}}\
67
77
  ```
68
78
 
@@ -179,12 +189,51 @@ import{"math", m}\
179
189
 
180
190
  ### AI — `pcAI`
181
191
 
182
- *(Stubreserved for future AI integration.)*
192
+ `pcAI` is a **built-in AI module** no import required. It supports conversation history, system prompts, and an interactive chat mode.
193
+
194
+ Configure it with environment variables:
195
+
196
+ | Variable | Default | Description |
197
+ |---|---|---|
198
+ | `CURL_AI_KEY` or `OPENAI_API_KEY` | *(none)* | Your API key |
199
+ | `CURL_AI_BASE_URL` | `https://api.openai.com/v1` | API base URL |
200
+ | `CURL_AI_MODEL` | `gpt-4o-mini` | Model name |
201
+
202
+ Works with **OpenAI**, **OpenRouter**, **Ollama**, or any OpenAI-compatible API.
203
+
204
+ **Ask a question:**
205
+
206
+ ```
207
+ var{reply, pcAI.ask{"What is the capital of France?"}}\
208
+ pcType{var{reply}}\
209
+ ```
210
+
211
+ **Set a persona (system prompt):**
212
+
213
+ ```
214
+ pcAI.context{"You are a friendly pirate who answers in rhymes."}\
215
+ var{reply, pcAI.ask{"What is 2 + 2?"}}\
216
+ pcType{var{reply}}\
217
+ ```
218
+
219
+ **Interactive chat loop** (type `exit` to quit):
220
+
221
+ ```
222
+ pcAI.chat{""}\
223
+ ```
224
+
225
+ **Other methods:**
183
226
 
184
227
  ```
185
- pcAI{".on", "You are a helpful assistant", "profanityControl"}\
228
+ var{s, pcAI.summarize{"some long text"}}\
229
+ var{a, pcAI.analyze{"some data"}}\
230
+ var{mood, pcAI.sentiment{"I love this!"}}\
231
+ var{t, pcAI.translate{"Bonjour — translate to English"}}\
232
+ pcAI.reset{""}\
186
233
  ```
187
234
 
235
+ > Conversation history is kept across `pcAI.ask` calls and auto-compacts when it gets long.
236
+
188
237
  ---
189
238
 
190
239
  ## Symbols
@@ -202,6 +251,9 @@ pcAI{".on", "You are a helpful assistant", "profanityControl"}\
202
251
  | `!=` | Not equals |
203
252
  | `=` | Assignment |
204
253
  | `+` | Concatenation / addition |
254
+ | `-` | Subtraction |
255
+ | `*` | Multiplication |
256
+ | `/` | Division |
205
257
 
206
258
  ---
207
259
 
@@ -227,6 +279,16 @@ func{sayBye}\
227
279
 
228
280
  ---
229
281
 
282
+ ## Example AI program
283
+
284
+ ```
285
+ pcAI.context{"You are a helpful tutor."}\
286
+ var{answer, pcAI.ask{"Explain what a variable is in one sentence."}}\
287
+ pcType{var{answer}}\
288
+ ```
289
+
290
+ ---
291
+
230
292
  ## License
231
293
 
232
294
  This project is licensed under the Apache License 2.0 (OSI-approved).
@@ -111,20 +111,18 @@ OTHER LANGUAGE BLOCKS:
111
111
  console.log("hi")
112
112
  }\\
113
113
 
114
- AI MODULE (import first):
115
- import{"ai", ai}\\
116
- ai.context{"You are a pirate."}\\ set bot persona (resets history)
117
- var{r, ai.ask{"What is 2+2?"}}\\ — ask a question (history kept)
114
+ AI MODULE (built-in, no import needed):
115
+ pcAI.context{"You are a pirate."}\\ — set bot persona (resets history)
116
+ var{r, pcAI.ask{"What is 2+2?"}}\\ ask a question (history kept)
118
117
  pcType{var{r}}\\
119
- ai.chat{""}\\ — start interactive chat loop (type exit to quit)
120
- ai.reset{""}\\ — clear conversation history
121
- ai.summarize{"some long text"}\\
122
- ai.analyze{"some data"}\\
123
- ai.sentiment{"I love this!"}\\ — returns: positive / negative / neutral
124
- ai.translate{"Bonjour to English"}\\
118
+ pcAI.chat{""}\\ — start interactive chat loop (type exit to quit)
119
+ pcAI.reset{""}\\ — clear conversation history
120
+ pcAI.summarize{"some long text"}\\
121
+ pcAI.analyze{"some data"}\\
122
+ pcAI.sentiment{"I love this!"}\\ — returns: positive / negative / neutral
123
+ pcAI.translate{"Bonjour to English"}\\
125
124
 
126
125
  IMPORTS:
127
- import{"ai", ai}\\ — built-in AI module
128
126
  import{"math", m}\\ — any Python stdlib or installed package
129
127
 
130
128
  === END OF CURL REFERENCE ===
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: curl-programming-lang
3
- Version: 1.4.1
3
+ Version: 1.4.2
4
4
  Summary: Curl is an open-source programming language built on Python technology
5
5
  Author: Ritvik Gautam
6
6
  License: Apache-2.0
@@ -47,9 +47,10 @@ git clone https://github.com/gautamritvik/Curl-Programming.git
47
47
  cd Curl-Programming
48
48
  pip install -e .
49
49
  ```
50
+
50
51
  ---
51
52
 
52
- ## Running the Curl terminal
53
+ ## Running the Curl terminal (REPL)
53
54
 
54
55
  ```
55
56
  curlang
@@ -61,6 +62,15 @@ curlang
61
62
  curlang [YOUR-FILE].curl
62
63
  ```
63
64
 
65
+ ## CLI flags
66
+
67
+ ```
68
+ curlang --version show version
69
+ curlang --license show license
70
+ curlang --credits show credits
71
+ curlang --help show help
72
+ ```
73
+
64
74
  ---
65
75
 
66
76
  ## Syntax Reference
@@ -81,7 +91,7 @@ pcType{"Hello, " + var{name} + "!"}\
81
91
  Prompts the user for input. The result is accessed anywhere with `input{ans}`.
82
92
 
83
93
  ```
84
- pcAsk{"What is your name?">>}\
94
+ pcAsk{"What is your name? >>"}\
85
95
  pcType{"You said: " + input{ans}}\
86
96
  ```
87
97
 
@@ -198,12 +208,51 @@ import{"math", m}\
198
208
 
199
209
  ### AI — `pcAI`
200
210
 
201
- *(Stubreserved for future AI integration.)*
211
+ `pcAI` is a **built-in AI module** no import required. It supports conversation history, system prompts, and an interactive chat mode.
212
+
213
+ Configure it with environment variables:
214
+
215
+ | Variable | Default | Description |
216
+ |---|---|---|
217
+ | `CURL_AI_KEY` or `OPENAI_API_KEY` | *(none)* | Your API key |
218
+ | `CURL_AI_BASE_URL` | `https://api.openai.com/v1` | API base URL |
219
+ | `CURL_AI_MODEL` | `gpt-4o-mini` | Model name |
220
+
221
+ Works with **OpenAI**, **OpenRouter**, **Ollama**, or any OpenAI-compatible API.
222
+
223
+ **Ask a question:**
224
+
225
+ ```
226
+ var{reply, pcAI.ask{"What is the capital of France?"}}\
227
+ pcType{var{reply}}\
228
+ ```
229
+
230
+ **Set a persona (system prompt):**
231
+
232
+ ```
233
+ pcAI.context{"You are a friendly pirate who answers in rhymes."}\
234
+ var{reply, pcAI.ask{"What is 2 + 2?"}}\
235
+ pcType{var{reply}}\
236
+ ```
237
+
238
+ **Interactive chat loop** (type `exit` to quit):
239
+
240
+ ```
241
+ pcAI.chat{""}\
242
+ ```
243
+
244
+ **Other methods:**
202
245
 
203
246
  ```
204
- pcAI{".on", "You are a helpful assistant", "profanityControl"}\
247
+ var{s, pcAI.summarize{"some long text"}}\
248
+ var{a, pcAI.analyze{"some data"}}\
249
+ var{mood, pcAI.sentiment{"I love this!"}}\
250
+ var{t, pcAI.translate{"Bonjour — translate to English"}}\
251
+ pcAI.reset{""}\
205
252
  ```
206
253
 
254
+ > Conversation history is kept across `pcAI.ask` calls and auto-compacts when it gets long.
255
+
207
256
  ---
208
257
 
209
258
  ## Symbols
@@ -221,6 +270,9 @@ pcAI{".on", "You are a helpful assistant", "profanityControl"}\
221
270
  | `!=` | Not equals |
222
271
  | `=` | Assignment |
223
272
  | `+` | Concatenation / addition |
273
+ | `-` | Subtraction |
274
+ | `*` | Multiplication |
275
+ | `/` | Division |
224
276
 
225
277
  ---
226
278
 
@@ -246,6 +298,16 @@ func{sayBye}\
246
298
 
247
299
  ---
248
300
 
301
+ ## Example AI program
302
+
303
+ ```
304
+ pcAI.context{"You are a helpful tutor."}\
305
+ var{answer, pcAI.ask{"Explain what a variable is in one sentence."}}\
306
+ pcType{var{answer}}\
307
+ ```
308
+
309
+ ---
310
+
249
311
  ## License
250
312
 
251
313
  This project is licensed under the Apache License 2.0 (OSI-approved).
@@ -7,7 +7,7 @@ def execute(ast, env=None):
7
7
  env = {
8
8
  "variables": {},
9
9
  "functions": {},
10
- "imports": {},
10
+ "imports": {"pcAI": CurlAIModule()}, # built-in, no import needed
11
11
  "last_input": None,
12
12
  }
13
13
  for stmt in ast:
@@ -82,6 +82,10 @@ class Parser:
82
82
  if token[0] == IDENTIFIER and self.peek() and self.peek()[0] == DOT:
83
83
  return self.parse_method_call_stmt()
84
84
 
85
+ # pcAI.method{arg}\ — built-in AI module, no import needed
86
+ if token[0] == KEYWORD and token[1] == "pcAI" and self.peek() and self.peek()[0] == DOT:
87
+ return self.parse_pcai_method_call_stmt()
88
+
85
89
  if token[0] != KEYWORD:
86
90
  raise SyntaxError(f"Expected a Curl keyword, got {token[0]} {repr(token[1])}")
87
91
 
@@ -217,6 +221,16 @@ class Parser:
217
221
  self.consume(LINE_END)
218
222
  return {"type": "method_call", "module": module, "method": method, "arg": arg}
219
223
 
224
+ def parse_pcai_method_call_stmt(self):
225
+ self.consume(KEYWORD, "pcAI")
226
+ self.consume(DOT)
227
+ method = self.consume(IDENTIFIER)[1]
228
+ self.consume(LBRACE)
229
+ arg = self.parse_concat_expr()
230
+ self.consume(RBRACE)
231
+ self.consume(LINE_END)
232
+ return {"type": "method_call", "module": "pcAI", "method": method, "arg": arg}
233
+
220
234
  def parse_import(self):
221
235
  self.consume(KEYWORD, "import")
222
236
  self.consume(LBRACE)
@@ -281,6 +295,16 @@ class Parser:
281
295
  if token[0] == KEYWORD:
282
296
  kw = token[1]
283
297
 
298
+ # pcAI.method{arg} as an expression — e.g. var{x, pcAI.ask{"prompt"}}\
299
+ if kw == "pcAI" and self.peek() and self.peek()[0] == DOT:
300
+ self.pos += 1 # consume pcAI
301
+ self.consume(DOT)
302
+ method = self.consume(IDENTIFIER)[1]
303
+ self.consume(LBRACE)
304
+ arg = self.parse_concat_expr()
305
+ self.consume(RBRACE)
306
+ return {"type": "method_call", "module": "pcAI", "method": method, "arg": arg}
307
+
284
308
  if kw == "var":
285
309
  self.pos += 1
286
310
  self.consume(LBRACE)
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "curl-programming-lang"
7
- version = "1.4.1"
7
+ version = "1.4.2"
8
8
  description = "Curl is an open-source programming language built on Python technology"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.7"